Why does MATLAB export the .png with a graph besides the right y-axis?
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
When opening the exported .png file I see that MATLAB has added or extended the graph beyond the right y-axis. I want to plot several shorter time series of a long temperature history and use xlimit to achieve my wanted time window. When exporting the figure as a svg or eps it is gone but then other information go missing.
How can I eliminate the 'extra' graph on the right side for my .png?
2 commentaires
Vinayak Choyyan
le 11 Avr 2023
Hi Tom,
This is not an expected behaviour. Please share your code and data with us so that we can investigate the issue.
Alternatively, you can create a technical service request at http://www.mathworks.com/support/servicerequests/index.html and send us the above details over the request.
Réponses (1)
David Wilkinson
le 22 Avr 2023
Modifié(e) : David Wilkinson
le 22 Avr 2023
Hello,
I just experienced a similar issue using R2023a.
Similar to yourself, I was plotting a figure with a left and right y-axis, using yyaxis left and yyaxis right.
The issue arose when I exported using exportgraphics.
There was a small part of the graph showing outside the main axes, past the right y-axis label.
To remedy this, I did the following:
- Set axis padding to be consistent for both the yyaxis left and yyaxis right plots (I used "axis tight")
- Set the x limit accordingly after the above line, for each plot
yyaxis left
plot(your_data)
axis tight
xlim([0 1])
yyaxis right
plot(your_other_data)
axis tight
xlim([-4 12])
exportgraphics(gcf,"test.png")
I hope this fixes your issue.
All the best,
David
Edit: Whilst I thought this fixed it, it appears having any xlim on a dual y-axis plot causes the issue...
3 commentaires
David Wilkinson
le 26 Avr 2023
Interestingly, I am seeing the issue with just
exportgraphics(gcf,"test.png")
There doesn't seem to be an explainable pattern here...
David Wilkinson
le 26 Avr 2023
This seems to be a recurrent issue. The linked forum states there's no practical workaround (without decreasing resolution).
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!