如何从绘图处理程序进行绘图? [英] How can I plot from a plot handler?
问题描述
我有情节的处理者或图形的处理者 示例:
I have the handler of the plot, or handle of the figure Example:
h = plot([1:0.2:10])
xx=get(h)
xx =
DisplayName: ''
Annotation: [1x1 handle]
Color: [0 0 1]
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerEdgeColor: 'auto'
MarkerFaceColor: 'none'
XData: [1x46 double]
YData: [1x46 double]
ZData: [1x0 double]
BeingDeleted: 'off'
ButtonDownFcn: []
Children: [0x1 double]
Clipping: 'on'
CreateFcn: []
DeleteFcn: []
BusyAction: 'queue'
HandleVisibility: 'on'
HitTest: 'on'
Interruptible: 'on'
Selected: 'off'
SelectionHighlight: 'on'
Tag: ''
Type: 'line'
UIContextMenu: []
UserData: []
Visible: 'on'
Parent: 173.0107
XDataMode: 'auto'
XDataSource: ''
YDataSource: ''
ZDataSource: ''
此处理程序包含所有绘图信息,如何再次绘图?这是plot
的一个简单示例,但应该也可以与slice
一起使用.
This handler contains all the plot information, how can I plot out again? This is a simple example with plot
but it is supposed to work with slice
as well.
推荐答案
如果我正确理解了您的问题,则希望使用结构xx
再现图.
提供的答案ccook正确,但是这是实现所需目标的较短方法:
If I understand your question correctly, you want to reproduce a plot using the struct xx
.
The answer ccook provided is on the right track, but here's a shorter way to achieve what you want:
figure
h2 = plot(0);
ro_props = [fieldnames(rmfield(xx, fieldnames(set(h2)))); 'Parent'];
xx = rmfield(xx, ro_props);
set(h2, xx)
最后一个set
命令使用结构xx
来设置所有值并复制您的绘图.请注意,在调用set
之前,已将ro_props
的只读属性从xx
中删除.
The last set
command uses struct xx
to set all the values and reproduce your plot. Note that the read-only properties ro_props
are removed from xx
before calling set
.
修改后的答案可以根据此建议自动检测只读属性.
modified answer to automatically detect read-only properties according to this suggestion.
这篇关于如何从绘图处理程序进行绘图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!