Plots: Designing and Saving

조회 수: 6 (최근 30일)
Philip
Philip 2011년 5월 14일
How can I include code in my M-File that builds a plot of my data with the following properties:
  • grid on
  • a vertical line at data point 10 running from the min to max y limits
  • title
  • xlabel and ylabels
I then want to be able to save this plot as an image with something like:
saveas(graph, 'graph.tiff');
Many thanks for any help you are able to give me!

채택된 답변

R Strange
R Strange 2011년 5월 14일
clc clear all clf
xLimits = [10 10]; %Set x limits here
yLimits = [-10 10]; %Set y limits here
hold
figL = line(xLimits, yLimits);
grid on %Turns major x and y grids on for plot
title('Put Title here') %Title Placement
xlabel('Put X Axis Label here') %x-axis label
ylabel('Put Y axis Label Here') %y-axis label
hold off
hfig = (gcf); %get plot handle
saveas(hfig, 'myGraphImage.tiff') %saves plot as an image in your current workspace dir
  댓글 수: 1
Philip
Philip 2011년 5월 14일
Thanks so much! I was struggling to find how to save the figure; and it seems 'gcf' was all I needed... Thanks again!

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

추가 답변 (1개)

Robert Cumming
Robert Cumming 2011년 5월 14일
help grid
help ylim %use this to get y limits so you can plot ( [10 10], [ymin ymax] )
help title
help xlabel
help ylabel
  댓글 수: 1
Philip
Philip 2011년 5월 14일
Thanks for your help! I've learnt a lot from these help files!

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

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by