How to set the datasource of a histogram programmatically?
Ältere Kommentare anzeigen
Hello all,
Does anyone know how to set the datasource of a histogram?
figure;
data = randn(10,1);
h = histogram(data);
linkdata on
h doesn't have a YDataSource property. It looks for me that you can only set the datasource manually in the figure.
Patrick
Akzeptierte Antwort
Weitere Antworten (2)
Bhuvnesh Singh
am 2 Mär. 2018
0 Stimmen
Hello Raptrick,
Yes the YDataSource' property is not available for histogram object.
For a workaround you can follow the below link:
Adam Nekimken
am 13 Jul. 2018
Hi Patrick,
I was having the same problem, and I think I found a workaround. First, run your script and do the manual linking, then save the figure. The next time you run the script, open the saved figure and call linkdata:
open(linkedFig.fig)
linkdata on
The figure retains the data link it had before, at least in my script. I've only tested this a bit, but it looks to have solved the problem for me.
Adam
Kategorien
Mehr zu Data Distribution Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
