How to plot multiplot with different range of data?
3 次查看(过去 30 天)
显示 更早的评论
I want to plot multiplot with different range of data, like x=(0,100,100), y=x^2, and x1=(0,60,60), y1=x1^4. The range of x and x1 should be consistent/overlap throuout the axis.
Alternatively, originally I want to plot the attached data. You can check the attached image to clarify where line 1 (W90) have 450 points in "wan_band.dat" datafile and line 2 (QE) has 251 points in "Pb-bands.dat.gnu" datafile. This data I have plot using gnuplot as shown in image file. I am sharing the code to plot only one set of data for your refernces, as below,
A=importdata("../wan_band.dat");
col1 = A(:,1 );
repeatlength = find(col1(2:end) == col1(1), 1);
x1 = reshape(A(:,1), repeatlength , []); y1 = reshape(A(:,2), repeatlength , []);
x1(end+1,:) = nan ; y1(end+1,:) = nan ;
plot(x1(:), y1(:),'b','DisplayName','E','LineWidth',2,'linestyle','-')
Please give me your suggestions about the same. If there is any information you need, let me know. I will keep waiting for your reply.
0 个评论
回答(1 个)
Mathieu NOE
2024-3-7
hello
maybe this ?
I normalized x1 and x2 so both plots would overlay nicely .
A=readmatrix("wan_band.dat");
[x1,y1] = myreshape(A);
mx1 = max(x1,[],'all');
B=readmatrix("Pb-bands.dat.gnu",'FileType','text');
[x2,y2] = myreshape(B);
mx2 = max(x2,[],'all');
plot(x1(:)/mx1, y1(:),'b','DisplayName','E','LineWidth',4)
hold on
plot(x2(:)/mx2, y2(:),'r*-','LineWidth',0.5)
hold off
function [x,y] = myreshape(data)
repeatlength = find(data(2:end,1) <eps, 1);
x = reshape(data(:,1), repeatlength , []);
y = reshape(data(:,2), repeatlength , []);
x(end+1,:) = nan ;
y(end+1,:) = nan ;
end
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!