Saving High Quality graphs within loop
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hii all,
I am using a package called borders in matlab to make colored maps. The problem is that the countries have to be colored one by one within a for loop. Now my aim is to save the depicted world in high resolution. My code looks as follows:
bord = borders('countries','r');
borders('countries','facecolor',[0.85,0.85,0.85])
axis tight
%W
for k=1:size(genepy_W_W_pred,1)
if genepy_W_W_pred.dummy_W(k)==1 %se è W_pred
borders(cell2mat(genepy_W_W_pred.ctry_W_W_pred(k)),'facecolor',genepy_W_W_pred.color(k,:))
end
end
exportgraphics(bord,'genepy_hs4_W_HQ.jpg','Resolution',500)
and it is basically creating a map of the world with red boundaries and coloring the countries one by one according to genepy_W_W_pred. I was trying to use exportgraphics(bord,'genepy_hs4_W_HQ.jpg','Resolution',500) but it raisses an handle issue.
Is there a way to name the figure appearing on the panel and save it in high resolution?
Thank you
0 Commenti
Risposte (1)
Bjorn Gustavsson
il 20 Lug 2021
The first input-argument to exportgraphics is supposed to be a handle to any type of axes. The handle you send in might very well be lost in the plotting function-calls you perform after you generate it. Maybe you get the proper handle to the current axes if you use an output-argument to the borders call in the loop:
bord = borders('countries','r');
borders('countries','facecolor',[0.85,0.85,0.85])
axis tight
%W
for k=1:size(genepy_W_W_pred,1)
if genepy_W_W_pred.dummy_W(k)==1 %se è W_pred
bord = borders(cell2mat(genepy_W_W_pred.ctry_W_W_pred(k)),...
'facecolor',genepy_W_W_pred.color(k,:));
end
end
exportgraphics(bord,'genepy_hs4_W_HQ.jpg','Resolution',500)
What are the benefits of using exportgraphics instead of print?
HTH
0 Commenti
Vedere anche
Categorie
Scopri di più su Colormaps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!