How to append an image to a plot curve

조회 수: 1 (최근 30일)
Ron Fredericks
Ron Fredericks 2022년 4월 21일
댓글: Ron Fredericks 2022년 4월 22일
I have an engineering plot using MATLAB plot command, and circuit schematic png image cooresponding to this plot. I would like to create one figure with the plot and the image stacked on tope of each other.
sample plot using command like this:
plot(app.timeArray, app.vcArray, ...
'LineWidth',app.LineWidthEditField.Value, 'Color','#ea710c')
Sample image using command like this
circuit = imread(which('RC_Charge_Circuit_Voltage.png'));
imshow(circuit)
Somehow I would like to have a script with one figure combining both the plot and the circuit image stacked (or appended) into one. The final image might look like this:

채택된 답변

Chris
Chris 2022년 4월 21일
편집: Chris 2022년 4월 21일
You should be able to use a tiled layout.
circuit = imread(which('RC_Charge_Circuit_Voltage.png'));
figure
tiledlayout(2,1)
nexttile
plot(app.timeArray, app.vcArray, ...
'LineWidth',app.LineWidthEditField.Value, 'Color','#ea710c')
nexttile
imshow(circuit)
If you want to make the figure background white afterward:
f = gcf;
f.Color = [1 1 1];
  댓글 수: 1
Ron Fredericks
Ron Fredericks 2022년 4월 22일
Thank you Chris.
With a little fiddling on figure size, your tilelayout method worked great! Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by