필터 지우기
필터 지우기

how can I change the line properties of a figure?

조회 수: 13 (최근 30일)
Mohammad
Mohammad 2014년 1월 29일
댓글: Iain 2014년 1월 29일
I have a .fig file,that has more than 1 graphs in it. I want to change each one's color and LineStyle. how can I do that? assume that the figure has 3 graphs.
  댓글 수: 2
José-Luis
José-Luis 2014년 1월 29일
Have you tried the figure editor? Or do you want to do it programatically?
Mohammad
Mohammad 2014년 1월 29일
yes I want to do it programatically, cause the user gives the figure to the function.

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

답변 (2개)

Iain
Iain 2014년 1월 29일
Theres no one obvious, quick fix.
get the properties of the figure:
fig_props = get(fig_no);
fig_props will contain the handles to each axis in the figure, and some annotations, colormaps, etc. get the properties of each child of fig_props:
child_props_556 = get(fig_props.Children(556))
That will be an axis or something else, you can tell by inspecting the properties. An axis will have more children, some of which will be the plotted lines.
Interrogate the axis's children:
possible_line_prperties = get(child_props_556.Children(2))
If you're happy that child_props_556.Children(2) (or whatever) is the line with properties that you want to change, then you can simply set it's properties.
set(child_props_556.Children(2),'Marker','x')
You will need to apply some intelligence and adaptability to figure out exactly how to do what you want to do.
  댓글 수: 1
Iain
Iain 2014년 1월 29일
Each of those functions can be used programattically, you just need to know what's going on in the figures.

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


Mischa Kim
Mischa Kim 2014년 1월 29일
As an alternative, open the figure, change it according to your requirements and generate the corresponding MATLAB code via File > Generate Code...
This will give you, amongst others, a good idea on how to programmatically change figure properties.
  댓글 수: 1
Mohammad
Mohammad 2014년 1월 29일
I've done that, I get this:
function createfigure(X1, YMatrix1)
%CREATEFIGURE(X1,YMATRIX1) % X1: vector of x data % YMATRIX1: matrix of y data
% Auto-generated by MATLAB on 29-Jan-2014 18:49:35
% Create figure figure1 = figure('PaperSize',[20.98404194812 29.67743169791]);
% Create axes axes1 = axes('Parent',figure1,'FontSize',6); box(axes1,'on'); hold(axes1,'all');
% Create multiple lines using matrix input to plot
plot1 = plot(X1,YMatrix1,'Parent',axes1);
set(plot1(1),'LineStyle',':',... 'Color',[0.494117647409439 0.494117647409439 0.494117647409439]);
set(plot1(2),'LineStyle','--',... 'Color',[0.235294118523598 0.235294118523598 0.235294118523598]);
set(plot1(3),'Marker','.','Color',[0 0 0]);
so my problem is not solved yet,cause I'm not the one who draws the graphs,but the graphs are in a .fig file that has been given to the function.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by