How to add a verteical pad obove and below the curve and graph style and color displays?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have two questions and the data is attached to the question:
Q1) Lest hand side code is for the figure on right hand side. How I can the color of each curve and curve style (dotted, asterisk, etc.) by myself in the code instead of MATLAB is chossing automatically?
Q2) In the figure on right hand side, qp at various f are plotted against VD. I have attached a data having VD and one of qp curve. the qp curves not of same length of VD. I want to add a pad above and below the qp curves such that it becomes equal to VD. The pad values should be between 0.001 to 0.002. How I can do it?
8 Kommentare
Mathieu NOE
am 1 Jun. 2022
FYI, a few options I tried to change automatically colors and linestyles (if that is ok for you) inside your loop
- had to modify the plot code as for the time being I cannot use the provided x, y data
- used some Filexchange submissions to get to this result
clc
% load('testdata.mat')
%% define your custom color order
% option 1 : manually : possible but takes time
% colors = [0 0 1;...
% 0 1 0;...
% 1 0 0;...
% 0 1 1;...
% 1 0 1;...
% 1 0.69 0.39;...
% 0.6 0.2 0;...
% 0 0.75 0.75;...
% 0.22 0.44 0.34;...
% 0.32 0.19 0.19]; %10x3 RGB array
% % or based on existing color maps
% colors = jet(60);
% or this
% % https://fr.mathworks.com/matlabcentral/fileexchange/42673-beautiful-and-distinguishable-line-colors-colormap
% colors = linspecer(60);
% even better :
func = @(x) colorspace('RGB->Lab',x); % https://fr.mathworks.com/matlabcentral/fileexchange/28790-colorspace-transformations
colors = distinguishable_colors(60,{'w','k'},func); % https://fr.mathworks.com/matlabcentral/fileexchange/29702-generate-maximally-perceptually-distinct-colors
%% define line styles and loop over them
linS = {'-','--',':','-.'};
figure(1),
hold on
c = 0;
cc = c;
for kk = 1:10:600
c= c+1;
cc = cc+1;
if cc>length(linS)
cc = 1 ; % restart from 1
end
% plot(Inv_Q(:,kk),VD,'Color',colors(n,:), 'DisplayName',sprintf('f = %d',f(kk)))
plot(VD1 + 0.1*kk,VD1,'Color',colors(c,:),'linestyle',linS{cc}, 'DisplayName',sprintf('f = %d',kk))
% plot(qp(:,kk),VD1,'Color',colors(c,:),'linestyle',linS{cc}, 'DisplayName',sprintf('f = %d',kk))
end
hold off
grid
legend('Location','best'); set(gca, 'ydir', 'reverse');
% xlim([0 3.0e-2]); ylim([1.8879e+03 2.1313e+03]);
xlabel('qp'); ylabel('VD');
Antworten (2)
Hiro Yoshino
am 1 Jun. 2022
Mathieu NOE
am 3 Jun. 2022
hello Nisar
this is my suggestion , and result
your last mat file does not contain the f data so I skipped that portion of code for the time being - should be fairly easy to reactivate it on your side
here a demo with a spacing of 5 netween succesive data (your original code was with a spacing of 10)
clc
load('testdata.mat')
[m,n] = size(Inv_Q);
%% define your custom color order
% option 1 : manually : possible but takes time and not flexible / robust
% colors = [0 0 1;...
% 0 1 0;...
% 1 0 0;...
% 0 1 1;...
% 1 0 1;...
% 1 0.69 0.39;...
% 0.6 0.2 0;...
% 0 0.75 0.75;...
% 0.22 0.44 0.34;...
% 0.32 0.19 0.19]; %10x3 RGB array
% % or based on existing color maps
% colors = jet(n);
% or this
% % https://fr.mathworks.com/matlabcentral/fileexchange/42673-beautiful-and-distinguishable-line-colors-colormap
% colors = linspecer(60);
% even better :
func = @(x) colorspace('RGB->Lab',x); % https://fr.mathworks.com/matlabcentral/fileexchange/28790-colorspace-transformations
colors = distinguishable_colors(n,{'w','k'},func); % https://fr.mathworks.com/matlabcentral/fileexchange/29702-generate-maximally-perceptually-distinct-colors
%% define line styles and loop over them
linS = {'-','--',':','-.'};
figure(1),
hold on
c = 0;
cc = c;
new_x = linspace(min(VD1),max(VD1),m);
for kk = 1:5:n
c= c+1;
cc = cc+1;
if cc>length(linS)
cc = 1 ; % restart from 1
end
plot(Inv_Q(:,kk),new_x,'Color',colors(c,:),'linestyle',linS{cc}); % plot(Inv_Q(:,kk),VD1, 'DisplayName',sprintf('f = %d',f(kk)))
leg_str{c} = (['Data ' num2str(kk)]);
end
hold off
grid
legend(leg_str,'Location','best'); set(gca, 'ydir', 'reverse');
xlim([0 3.0e-2]); ylim([1.8879e+03 2.1313e+03]);
xlabel('qp'); ylabel('VD');
0 Kommentare
Siehe auch
Kategorien
Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!