Merging 10 scatter plots produced with different RNG sequences
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi all
I have produced 10 scatter graphs which are similar and I wanted to merge the files into a scatter graph with range bars (i.e. Median, Upper Q, Lower Q)
I have the 10 figures saved as .fig and .m/.mat files.
Any tips for doing this please?
0 comentarios
Respuestas (3)
Julian Hapke
el 4 de Abr. de 2016
you can access the data of each plot by
X=cell(10,1)
Y=X
for ii = 1:10
f = open('figure_ii.fig') % use the correct file names here
X{ii} = get(get(gca,'Children'),'XData')
Y{ii} = get(get(gca,'Children'),'YData')
close(f)
end
to calculate your new data use "quantile"
help quantile
also have a look at
help errorbar
to plot the ranges you calculated.
I hope this helps, otherwise you have to specify your question.
0 comentarios
Om
el 4 de Abr. de 2016
1 comentario
Julian Hapke
el 5 de Abr. de 2016
I assume your variable names in each mat-file are the same, so if you just
load('example.mat')
it overrides your current values. So what you could do is just load your data into an array of structures:
data(10).median = []
data(10).lq = []
data(10).uq = []
for ii = 1:10
data(ii) = load('file.mat')
end
to get a vector of each array entry use
[data.median]
and so on
Om
el 5 de Abr. de 2016
Editada: Om
el 5 de Abr. de 2016
2 comentarios
Julian Hapke
el 7 de Abr. de 2016
Editada: Julian Hapke
el 7 de Abr. de 2016
I'm not sure what I'm looking at in your plot and you have to be clearer about what is the data you have and what is the plot you want to see. my guess: you want an error bar plot for median, lq and uq, with 10 differing values for median lq and uq at each of 11 x-values. Here you go with some example data, that resembles your plot:
function tst
close all
%
% generate dummy data
data(10).median = [];
data(10).lq = [];
data(10).uq = [];
x = (0:10)';
for ii = 1:10
data(ii).x = (0:10)';
data(ii).median = (linspace(0,0.25,11)+(rand(1,11)*0.02-0.02).*linspace(0,1,11))';
data(ii).uq = (linspace(0,0.35,11)+(rand(1,11)*0.1-0.1).*linspace(0,1,11))';
data(ii).lq = (linspace(0,0.2,11)+(rand(1,11)*0.1-0.1).*linspace(0,1,11))';
end
% plot scatter of everything
figure(1)
hold all
for ii = 1:10
scatter(x,[data(ii).median],'g')
scatter(x,[data(ii).uq],'r')
scatter(x,[data(ii).lq],'b')
end
%
% calculate data for errorbars
errby = mean([data(:).median],2);
errbdwn = mean([data(:).median],2)-min([data(:).median],[],2);
errbup = max([data(:).median],[],2)-mean([data(:).median],2);
% plot errorbars
errorbar(x,errby,errbdwn,errbup,'Color','g');
%
errby = mean([data(:).uq],2);
errbdwn = mean([data(:).uq],2)-min([data(:).uq],[],2);
errbup = max([data(:).uq],[],2)-mean([data(:).uq],2);
errorbar(x,errby,errbdwn,errbup,'Color','r');
%
errby = mean([data(:).lq],2);
errbdwn = mean([data(:).lq],2)-min([data(:).lq],[],2);
errbup = max([data(:).lq],[],2)-mean([data(:).lq],2);
errorbar(x,errby,errbdwn,errbup,'Color','b');
end
Julian Hapke
el 7 de Abr. de 2016
you mentioned earlier, that each of your 10 mat files contains 3 values, so I don't understand where all the plots in your picture come from, enlighten me.
Ver también
Categorías
Más información sobre Errorbars en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!