How to redraw the current saved histogram "fig" file

4 views (last 30 days)
Hello,
I currently have the saved "fig" file generated by Matlab by using the default histogram "bin" size as I do not know what the histogram plot output would be.
For example:
Histogram_Plot=histogram(Histogram_Inputt_Plot_data);
savefig('Histogram_Plot.fig')
Since I got the saved "Histogram_Plot.fig" file, now I want to redraw the histogram using different bin. How can I extract the data or manupulate from the existing saved fig file and redraw with different bin size now that I got the data from the saved fig file. The reason I want to do this because I do not want to rerun the simulation again and I want use the data I already got from the saved fig file.
Thanks,
Charles

Answers (1)

Kevin Rawson
Kevin Rawson on 14 Apr 2019
Provided only the histogram is in the figure, the following should work:
hFig = open('Histogram_Plot.fig');
hAxes = hFig.Children;
hHist = hAxes.Children;
hHist.BinEdges = [ <your new bins here> ];
If you have additional lines in the figure (i.e. the figure axes have multiple children), you'll have to ensure you get the correct handle of your histogram.

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!