Reputation: 119
Here is some code for plotting cos(x) and (sinx)
t = -pi:0.01:(pi);
x = cos(t);
y = sin(t);
h1=plot(t,x,'b', 'MarkerSize', msz); hold on;
h2=plot(t,y,'r', 'MarkerSize', msz);
alw = 0.75; % AxesLineWidth
fsz = 11; % Fontsize
lw = 1.5; % LineWidth
msz = 8; % MarkerSize
pos = get(gcf, 'Position');
set(h1,'linewidth',lw)
% axis([-pi pi -1 1])
set(gcf, 'Position', [pos(1) pos(2) width*100, height*100]); %<- Set size
set(gca, 'FontSize', fsz, 'LineWidth', alw); %<- Set properties
legend('cos(t)','sin(t)','Location','NorthWest')
title('Plot of cos(x) and sin(x) between -2\pi and 2\pi')
set(gca,'XTick',-pi:pi/2:pi)
set(gca,'XTickLabels',{'-\pi','-\pi/2','0','\pi/2','\pi'})
Although it works fine, I am not satisfied with the quality of the produced plot. The lines in my plot appear inconsistent an of poor quality.
How can I get Matlab to create picture with quality similar to this:
Upvotes: 0
Views: 218
Reputation: 6060
If you want really nice plots, I recommend matlab2tikz.
I used this in my thesis and it looks really beautiful. the script converts your matlab figure into a tikz/pgfplot file. You can include that in your LaTeX document. Or just use LaTeX to create a PDF file.
I know, that you can export PDF directly from MATLAB. While you can increase the line with etc., it still falls short of tikz outstanding quality.
Upvotes: 3
Reputation: 5723
I am guessing that when you are referring to quality you mean optical quality? As in saving a matlab image and using it elsewhere? If I am mistaken then the following are of no use.
Matlab typical graphs are vector graphics so they should scale adequate enough. So, I guess you have a problem with the format you save your image?
Anyway, matlab stores the images in various formats you have to choose a different one. Don't choose jpg
as it creates artifacts, use png
for instance. I am not sure if you want this, but you can also play with the line widths.
Finally another trick is to save the image to greater size than needed and then when shown in reduced size it will see more natural. This approach requires that you increase the line widhts as in other case you will get flicks and breaks in lines.
Upvotes: 1