How to plot and print two graphs in a same page?
古いコメントを表示
I have been trying two put two graphs in a single make and make it PDF. But the border of the pages is not equal on all the sides and the grpahs are tend to shift. the positions of the graphs are dictated by the 'PaperPosition' command which is applied after the 2nd graph. I need both the grpah on the same page with equal border margin and grpah lengths (height and width). I have added the code for clarification. Is there any way that I can use to solve the problem. The code is given below:
p=1
x=rand(90,1)
subplot(2,1,1)
plot(x)
grid on;
grid minor;
str = sprintf('Random data for experiment');
xlabel({'X-axis',str});
ylabel('Y-axis');
t=0:0.01:4*pi
f=1
y=5*sin(2*pi*f*t)
subplot(2,1,2)
plot(t,y)
grid on;
grid minor
str = sprintf('Sinewave for experiment');
xlabel({'Time(s)',str});
ylabel('Voltage(v)');
x_width1=8.7;
y_width1=11;
set(gcf, 'PaperPosition', [-0.1 0.4 x_width1 y_width1]);
7 件のコメント
This looks good. What is the problem with this?
p=1;
x=rand(90,1);
subplot(2,1,1)
plot(x)
grid on;
grid minor;
str = sprintf('Random data for experiment');
xlabel({'X-axis',str});
ylabel('Y-axis');
t=0:0.01:4*pi;
f=1;
y=5*sin(2*pi*f*t);
subplot(2,1,2)
plot(t,y)
grid on;
grid minor
str = sprintf('Sinewave for experiment');
xlabel({'Time(s)',str});
ylabel('Voltage(v)');
ANANTA BIJOY BHADRA
2022 年 4 月 19 日
Adam Danz
2022 年 4 月 19 日
What function are you using to print to PDF?
ANANTA BIJOY BHADRA
2022 年 4 月 19 日
Nikhil Sapre
2022 年 4 月 20 日
編集済み: Nikhil Sapre
2022 年 4 月 20 日
Can you try using the print function and pass in the figure handle to it?
p=1;
x=rand(90,1);
subplot(2,1,1)
plot(x)
grid on;
grid minor;
str = sprintf('Random data for experiment');
xlabel({'X-axis',str});
ylabel('Y-axis');
t=0:0.01:4*pi;
f=1;
y=5*sin(2*pi*f*t);
subplot(2,1,2)
plot(t,y)
grid on;
grid minor
str = sprintf('Sinewave for experiment');
xlabel({'Time(s)',str});
ylabel('Voltage(v)');
set(gcf, 'PaperPosition', [-0.1 0.4 x_width1 y_width1]);
print(gcf, '-dpdf', 'test');
Adam Danz
2022 年 4 月 20 日
If you're using R2020a or later you could use exportgraphics but the figure borders will be trimmed.
ANANTA BIJOY BHADRA
2022 年 4 月 20 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Numerical Integration and Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
