The shape of lines in a figure

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

Posting the images would have been easier on us. I dislike firing up MS Word. (Too many bad associations with Catbert-inspired paperwork.)
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?

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 30 Dec 2012
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
Image Analyst on 30 Dec 2012
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).

13 Comments

The plot might have been done with --: if the points were close together. Or the sidemarks might be markers. Hard to tell.
I am not using '--' and it is showing a broken line (not smooth as his and it should be without colors). This is the code I am using:
f = @(x,y) (1-x).^2 + 100*(y-x.^2).^2;
x = linspace(-2,2);
y = linspace(-1,3);
[xx,yy] = meshgrid(x,y);
ff = f(xx,yy);v=[1.96,10,50,100,150,200,250,300]; plot(1,1,'o','MarkerSize', 5, 'MarkerFaceColor', 'k');
hold on;
plot(1,1,'x', 'MarkerSize', 15, 'MarkerFaceColor', 'k');hold on
LW = 'linewidth';
FS = 'fontsize';
MS = 'markersize';
[c,h]=contour(x,y,ff,v);
clabel(c,h,'manual');
set (h, 'LineWidth', 2) axis([-2 2 -1 3]), axis square, hold on
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.
So does it give exactly as the second screenshot? How would I do that? I mean the change
Did you try export_fig?
Yes...it gives me the same but with transparent background
Image Analyst
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.)
@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.
The screenshot looks perfect if I can reproduce it, but what is "GXFigure" here?
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.
As long as I can not reproduce this figure for now, I will patiently wait for your Alpha 3 in a week. Hopefully it will be ready then
Thanks
BTW, when I reproduced this figure it still did not give me drawing lines as smooth as yours in that figure! Any ideas here what is going on?
@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

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Asked:

on 29 Dec 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!