The shape of lines in a figure
Show older comments
Hello,
Why do the drawn lines in my figure look thin and not smooth curved lines? In this link you will see the first figure (my figure) and in the second one is the target (just black and white, thicker lines and smooth drawing lines): http://speedy.sh/zaK8p/test.docx
Thanks
2 Comments
Walter Roberson
on 30 Dec 2012
Posting the images would have been easier on us. I dislike firing up MS Word. (Too many bad associations with Catbert-inspired paperwork.)
Jan
on 30 Dec 2012
Where do the figures look as described? On the screen, when exported to a pixel image and magnified, when exported to an EPS, but after an import to Word only the pixel-preview is displayed on the screen, but when printed to paper or to a PDF the graphics are excellent?
Answers (2)
Walter Roberson
on 30 Dec 2012
0 votes
I would suggest plotting with no marker specified, with the default line stype ('-') and perhaps with a LineWidth given. LineWidth is in points and the default is 1/2 point.
The graph you showed appeared to either have markers or to be using '--.' line style.
Image Analyst
on 30 Dec 2012
0 votes
Try adding this option to whatever function (plot, contour, etc.) you used to plot the curves:
..... 'LineWidth', 3, ........
That should thicken them up. LineWidth is a common option used by a bunch of functions.
Your plot (the top colored one) looks fine to me. I don't see broken line like Walter. Tell me what "the target" is and why it apparently rasterizes the plot and loses the colors. Because of the rasterization/quantization/digitization/sampling (whatever you want to call it) and the apparent anti-aliasing being done along with that, it gives a choppy appearance to the curves on the bottom plot on "the target" (whatever that is).
Inthe future, just upload a screenshot directly: http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
13 Comments
Walter Roberson
on 30 Dec 2012
The plot might have been done with --: if the points were close together. Or the sidemarks might be markers. Hard to tell.
Image Analyst
on 30 Dec 2012
I ran your code. I get no dashed or broken lines at all. They are perfectly solid. Perhaps it has to do with the video adapter you and Walter are using. Maybe you should change the renderer to Painter, zBuffer, or something that works better.
Sam Alex
on 30 Dec 2012
Image Analyst
on 30 Dec 2012
Did you try export_fig?
Sam Alex
on 30 Dec 2012
Image Analyst
on 30 Dec 2012
Edited: Image Analyst
on 30 Dec 2012
You aren't saving the image out as JPG are you? And then importing into Word. Because jpegging the image will reduce image quality. You might try this link: http://www.mathworks.com/matlabcentral/answers/56890-publication-quality-graphics-in-matlab and use Waterloo. (I have no experience with it.)
Malcolm Lidierth
on 30 Dec 2012
Edited: Malcolm Lidierth
on 30 Dec 2012
@IA Thanks for the plug!
This case turned up a bug that I've fixed and will soon push to the Git repo (closing the paths for contours when I should not have done).
Here is the code:
x = linspace(-2,2);
y = linspace(-1,3);
f = @(x,y) (1-x).^2 + 100*(y-x.^2).^2;
[xx,yy] = meshgrid(x,y);
ff = f(xx,yy);
v=[1.96,10,50,100,150,200,250,300];
GXFigure()
c=contour(gxgca, x,y,ff,v);
c.getObject().setLabelled(true);
And the result (as SVG so it may not show on all browsers - in that case take a look at the PNG version at http://waterloo.sourceforge.net/images/WebAnswerImages/MLAnswer_30-12-2012.png):

Labelling clearly needs more work - but this can be output to SVG/PDF so you can always edit in Illustrator/Inkscape etc.
Sam Alex
on 30 Dec 2012
Malcolm Lidierth
on 30 Dec 2012
Sam GXFigure is a "Project Waterloo" MATLAB OOP class that uses a MATLAB figure underneath but allows Java graphics to be included as well as MATLAB graphics.
For details, see Yair's Undocumented MATLAB blog from last month: http://undocumentedmatlab.com/blog/waterloo-graphics-examples/
The Project Waterloo website is at:
Note the plot above needed a fix - so you will need to do a Git clone and build once I have pushed the fix or wait for the Alpha3 build in a week or so. Waterloo graphics is new and I am adding features pretty much daily.
Sam Alex
on 30 Dec 2012
Sam Alex
on 30 Dec 2012
Malcolm Lidierth
on 30 Dec 2012
@Sam
You should see no difference when the figure is saved to a vector format - that has no dependency of the screen resolution. Double-click the graph and choose Save As button in the Graph Editor GUI that appears and choose PDF/SVG output. Or choose Copy to clipboard (not Copy image) - that copies to PDF allowing high-quality graphs to be pasted straight into Word (again re-rendered - all using Apache Batik under the hood).
On screen, smoothness will vary with hardware, OS and the Java Virtual Machine being used - on a Mac for example with the Apple JVM using the Quartz graphics pipeline, the lines are pretty smooth. On Windows, you will likely see some wiggles. It may be worth updating to the latest JRE on Windows and activating Direct X via a java.opts file - much faster graphics then, too.
If you have any feature requests for MATLAB, do post them at http://www.mathworks.com/matlabcentral/answers/56890-publication-quality-graphics-in-matlab. I'll be checking there regularly.
ML
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!