Mathematica : Draw a simple line, make into image

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 4K views
Science Advisor
Gold Member
Messages
458
Reaction score
40
I wish to create, in Mathematica, an image.

I have a set of lines, for the sake of a test, let's 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 doesn't work. Any help? The lines should be on the left side of the picture.
 
Physics news on Phys.org
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.