Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica : Draw a simple line, make into image

  1. Jun 19, 2013 #1

    Hepth

    User Avatar
    Gold Member

    I wish to create, in Mathematica, an image.

    I have a set of lines, for the sake of a test, lets use:

    {{10,0},{40,100}}
    {{20,0},{80,100}}

    Now I want my image to be 400x100 pixels, and the lines to appear as if their coordinates are those of the points in the image. If I do:

    Graphics[Line[{{{10, 0}, {40, 100}}, {{20, 0}, {80, 100}}}],
    ImageSize -> {400, 100}, AlignmentPoint -> {Left, Bottom}]

    It doesnt work. Any help? The lines should be on the left side of the picture.
     
  2. jcsd
  3. Jun 20, 2013 #2
    Wrap a Show[] around your Graphics[]

    In[1]:= Show[Graphics[Line[{{{10, 0}, {40, 100}}, {{20, 0}, {80, 100}}}], ImageSize -> {400, 100}, AlignmentPoint -> {Left, Bottom}]]

    Out[1]= ...ImageSnipped...

    But this doesn't address your "The lines should be on the left side of the picture."

    Maybe what you want is to specify the PlotRange option, something like this

    In[2]:= Show[Graphics[Line[{{{10, 0}, {40, 100}}, {{20, 0}, {80, 100}}}], ImageSize -> {400, 100}, AlignmentPoint -> {Left, Bottom}], PlotRange -> {{0, 400}, {0, 100}}]

    Out[2]= ...ImageSnipped...

    But there are lots of options you may need to explore to get a graphic to be just the way you want.
     
  4. Jun 20, 2013 #3

    Hepth

    User Avatar
    Gold Member

    PlotRange worked! Thanks a million. Now to post another question....
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Mathematica : Draw a simple line, make into image
Loading...