How to export high resolution line graphs to png, tiff, etc

5 views (last 30 days)
I am not sure if this has already been solved, but here goes.
I need to export to png or tiff 2D graphs of lines in high resolution (600dpi or higher). Everything is ok when all lines are solid, but when dotted, dashed or other combinations are present the exported image looks very bad. The problem is that the lines and dots do not scale correctly when exported and and up being very very thin very numerous. The end result is a "hazy" solid line that only looks like a dotted one when you fully zoom in. The same goes for the grid if I add it.
For now what I do is after doing all my plotting and manipulation in Matlab, I export a .dat file of the quantity I want to plot and save it to disk. Then I use another program for the plotting, such as Origin lab.
I have tried various files here on the website but nothing seems to work well. I also know that similar problems exist in python which runs similar to Matlab. Note I do not want vector graphs.
Thanks in advance :) Best, Paris

Answers (2)

Richard Quist
Richard Quist on 24 May 2016
If you believe the lines aren't scaling correctly you should contact technical support so they can look into the issue.
It's possible that what you're seeing is just an artifact of how the viewing application is displaying the image. If it is not being shown at its native size and resolution then the image will be scaled ... and scaling almost always results in poorer quality for bitmapped graphics.
One approach that might help would be to increase the line widths ... this would give the viewing application more pixels per line and it may do a better job when showing the scaled version.
l = plot(rand(3));
set(l(1), 'linestyle', '-.');
set(l(2), 'linestyle', '--');
set(l(3), 'linestyle', ':');
% increase line widths for all lines
set(l, 'linewidth', 1);
print -djpeg -r600 lines.jpg
  1 Comment
Paris Panagiotopoulos
Paris Panagiotopoulos on 24 May 2016
Thank you for your suggestion but it does not work well. It actually showcases the problem pretty well. If you compare the on screen .fig file and the exported .jpg the spacing between the dots and lines is very different. This is the problems with scaling I am talking about. It's not the width of the line that is wrong its the spacing of the dots and lines.

Sign in to comment.

KSSV on 24 May 2016
  1 Comment
Paris Panagiotopoulos
Paris Panagiotopoulos on 24 May 2016
I have tried this in the past but it did not look anywhere close to what other programs produce. I will give it a try again today.

Sign in to comment.


Find more on Graphics Performance 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!