How can I save lines in MATLAB as an image?
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Nora Hora
il 9 Dic 2016
Risposto: Image Analyst
il 10 Dic 2016
After I finished the transformation with my program I would like to export the images which contains different number of lines. I got error when I try to imwrite it as the following:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/158827/image.png)
Error using imwrite (line 420)
Expected DATA to be one of these types:
numeric, logical
Instead its type was matlab.graphics.primitive.Line.
This is how they look like when I plot them. I only need the image of the scales, and the others are not required for me. (I also tried saveas but I couldn't remove the unnecessary parts.)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/158828/image.png)
Any solution? Thank you in advance for your help!
1 Commento
Image Analyst
il 10 Dic 2016
I'm not sure how Laslo's solution removed the lines and saved only the axes scales. I think it would save everything - scales and blue lines.
It seems to me you should plot the lines, getting the handles, then put hold on, then delete the handles. That would hopefully leave the axes as-is but not have the blue lines (which you do not want).
Risposta accettata
Image Analyst
il 10 Dic 2016
Try this:
x = rand(1,10)*20
y = rand(1,10)*30
hLine = plot(x, y, 'b-');
% Save axes ranges.
yl = ylim();
xl = xlim()
grid on;
% Get rid of blue lines.
delete(hLine);
% Restore axes ranges from 0-1 to what they were during the blue lines.
xlim(xl);
ylim(yl);
Now you have an axes showing just the scales that were present while the blue lines were showing. No blue lines are showing. Now you can use export_fig(), hgsave(), print() or whatever to save the axes.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Line Plots 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!