I'm currently using the following code to save a graph:
g=figure;
p=copyobj(myAxes,g);
set(p,'Units','normalized','OuterPosition',[0 0 1 1]);
print(g,'-dbmp','tempfile.bmp');
close(g);
This works pretty well, except that if the graph in myAxes has a datatip, this datatip is not saved in the bitmap. Does anybody know a way to copyobj the datatip along with the graph?
|
|
0
|
|
|
|
Reply
|
Andy
|
1/13/2011 7:06:05 PM |
|
On 11-01-13 01:06 PM, Andy wrote:
> I'm currently using the following code to save a graph:
>
> g=figure;
> p=copyobj(myAxes,g);
> set(p,'Units','normalized','OuterPosition',[0 0 1 1]);
> print(g,'-dbmp','tempfile.bmp');
> close(g);
>
> This works pretty well, except that if the graph in myAxes has a datatip, this
> datatip is not saved in the bitmap. Does anybody know a way to copyobj the
> datatip along with the graph?
I believe the datatip may be created within a different axes.
|
|
0
|
|
|
|
Reply
|
I
|
1/13/2011 7:28:14 PM
|
|
I am too much me <roberson@hushmail.com> wrote in message <ignjr0$mpu$1@nrc-news.nrc.ca>...
> On 11-01-13 01:06 PM, Andy wrote:
> > I'm currently using the following code to save a graph:
> >
> > g=figure;
> > p=copyobj(myAxes,g);
> > set(p,'Units','normalized','OuterPosition',[0 0 1 1]);
> > print(g,'-dbmp','tempfile.bmp');
> > close(g);
> >
> > This works pretty well, except that if the graph in myAxes has a datatip, this
> > datatip is not saved in the bitmap. Does anybody know a way to copyobj the
> > datatip along with the graph?
>
> I believe the datatip may be created within a different axes.
Some poking around with Yair's findjobj (http://www.mathworks.com/matlabcentral/fileexchange/14317-findjobj-find-java-handles-of-matlab-graphic-objects) suggests that this is not the case.
But I'm guessing everything about a data tip is nearly invisible from a programmatic point of view. For example, run the following:
x=linspace(0,10,100);
y=sin(x);
f=figure;
a=axes('parent',f);
p=plot(a,x,y);
% add a few data tips
findjobj(f)
Now if you right click on one of the datatips and "Export handle to findjobj_hdls", you'll have the handle for the data cursor in your workspace. I then renamed mine to dc. Then you can see all of the properties of the data cursor:
>> get(dc)
Annotation: [1x1 hg.Annotation]
DisplayName: ''
HitTestArea: 'off'
BeingDeleted: 'off'
ButtonDownFcn: []
Children: [0x1 double]
Clipping: 'on'
CreateFcn: []
DeleteFcn: []
BusyAction: 'queue'
HandleVisibility: 'off'
HitTest: 'on'
Interruptible: 'on'
Parent: 1109.00012207031
SelectionHighlight: 'on'
Tag: ''
Type: 'hggroup'
UserData: []
Selected: 'off'
FontAngle: 'normal'
FontName: 'Helvetica'
FontSize: 8
FontUnits: 'points'
FontWeight: 'normal'
EdgeColor: [0.8 0.8 0.8]
BackgroundColor: [1 1 0.933333333333333]
TextColor: [0 0 0]
Marker: 'square'
MarkerSize: 10
MarkerEdgeColor: [1 1 0.862745098039216]
MarkerFaceColor: [0 0 0]
MarkerEraseMode: 'normal'
Draggable: 'on'
String: [1x19 char]
Visible: 'on'
StringFcn: []
UpdateFcn: []
UIContextMenu: [1x1 uicontextmenu]
Host: [1x1 graph2d.lineseries]
Interpolate: 'off'
Draggable seemed like a pretty unique property name. I've never seen anything else with this property, and I'm sure this would uniquely identify data cursors in my program. But:
>> findobj('-property','Draggable')
ans =
Empty matrix: 0-by-1
I've also tried a lot of other properties, and none of them were found by findobj. So I don't know how I can programmatically find the data cursors. The findjobj results make it look like they're children of the axes object, but get(a,'children') will only return the handle for the lineseries object.
Any other ideas?
|
|
0
|
|
|
|
Reply
|
Andy
|
1/13/2011 9:03:04 PM
|
|
Okay, I think I've gotten closer:
%%
x=linspace(0,10,100);
y=sin(x);
f=figure;
dcm=datacursormode(f);
a=axes('parent',f);
p=plot(a,x,y);
%%
% add some data cursors before running this cell
get(dcm,'DataCursors')
So now that I can get the handles to the data cursors, I need to be able to copy them. Unfortunately, the data cursors are of class graphics.datatip, which does not apparently count as a graphics object so it cannot be copied via copyobj.
For the record, if after running the above script you run:
>> print(f,'-dbmp','test.bmp');
you will have a bitmap image of the graph including the data cursor. In my application, the axes is in a subpanel inside the figure, and the print command requires the handle graphics object you pass to it to be a figure. I have been just copying the graph to a new figure, using the print command, and deleting the figure.
If anybody can help me copy the data cursors over, or if anybody has a better way to save my graph without needing to make a copy, please let me know.
|
|
0
|
|
|
|
Reply
|
Andy
|
1/13/2011 9:25:22 PM
|
|
On 11-01-13 03:03 PM, Andy wrote:
> I am too much me <roberson@hushmail.com> wrote in message
>> I believe the datatip may be created within a different axes.
> Some poking around with Yair's findjobj
> (http://www.mathworks.com/matlabcentral/fileexchange/14317-findjobj-find-java-handles-of-matlab-graphic-objects)
> suggests that this is not the case.
Checking further, the datatip is a hggroup object with HandleVisibility off
that is a child of the axes that the datatip is relative to.
|
|
0
|
|
|
|
Reply
|
By
|
1/13/2011 9:37:48 PM
|
|
"By learning you will teach; by teaching you will learn." <roberson@hushmail.com> wrote in message <ignrdu$qkt$1@nrc-news.nrc.ca>...
> On 11-01-13 03:03 PM, Andy wrote:
> > I am too much me <roberson@hushmail.com> wrote in message
>
> >> I believe the datatip may be created within a different axes.
>
> > Some poking around with Yair's findjobj
> > (http://www.mathworks.com/matlabcentral/fileexchange/14317-findjobj-find-java-handles-of-matlab-graphic-objects)
> > suggests that this is not the case.
>
> Checking further, the datatip is a hggroup object with HandleVisibility off
> that is a child of the axes that the datatip is relative to.
Firstly, since the datatips have HandleVisibility off, you need to use findall rather than findobj:
>> findobj(gca,'-property','Draggable')
ans =
Empty matrix: 0-by-1
>> findall(gca,'-property','Draggable')
ans =
199.0009765625
>> findall(gca,'-isa','graphics.datatip') <= this is better I would think...
ans =
199.0009765625
Secondly, you can get the handles directly, by accessing the axes's hidden children:
>> allchild(gca)
ans =
207.0009765625
206.0009765625
205.0009765625
204.0009765625
199.0009765625
184.00146484375
Thirdly, for screen-capturing the axes as-is, you don't need any of the above (interesting as they may be) - you just need a good screen-capture utility. Here's one such utility that you can run in Matlab on any chosen figure/axes handle:
http://www.mathworks.com/matlabcentral/fileexchange/24323-screencapture
Yair Altman
http://UndocumentedMatlab.com
|
|
0
|
|
|
|
Reply
|
Yair
|
1/14/2011 11:33:05 AM
|
|
Thanks, Yair! That screen capture utility is great. This completely solves my problem.
|
|
0
|
|
|
|
Reply
|
Andy
|
1/14/2011 2:25:05 PM
|
|
|
6 Replies
257 Views
(page loaded in 0.069 seconds)
Similiar Articles: Saving graphs with datatips - comp.soft-sys.matlabOn 11-01-13 01:06 PM, Andy wrote: > I'm currently using the following code to save a graph: > > g=figure; > p=copyobj(myAxes,g); > set(p,'Units','normalized ... datacursormode and subplot - comp.soft-sys.matlabSaving graphs with datatips - comp.soft-sys.matlab datacursormode and subplot - comp.soft-sys.matlab Hi, I have an interactive application in which there are two subplot ... Saving 'Visible','off' figures - comp.soft-sys.matlabSaving graphs with datatips - comp.soft-sys.matlab I'm currently using the following code to save a graph: g=figure ... String: [1x19 char] Visible: 'on ... since the ... Export graph from a GUI is not working - comp.soft-sys.matlab ...Saving graphs with datatips - comp.soft-sys.matlab I'm currently using the following code to save a graph: g=figure; p=copyobj ... data tips findjobj(f) Now if you right ... label (annotate) bar graph - comp.soft-sys.matlabPlot vertical lines on plots - comp.soft-sys.matlab label (annotate) bar graph - comp.soft-sys.matlab Plot vertical lines on plots ... How to plot half-normal probability ... Export figure to *.emf. Two results on different PCs. - comp.soft ...Saving graphs with datatips - comp.soft-sys.matlab... you right click on one of the datatips and "Export ... The findjobj results make it look like they're ... Data Cursor in Matlab Figure - comp.soft-sys.matlabMerging of plots / figures - comp.soft-sys.matlab I have generated a few graphs using m files. For the purpose of study and comparison is it possible to merge the data of ... MarkerFaceColor - comp.soft-sys.matlabSaving graphs with datatips - comp.soft-sys.matlab... TextColor: [0 0 0] Marker: 'square' MarkerSize: 10 MarkerEdgeColor: [1 1 0.862745098039216] MarkerFaceColor: [0 0 0 ... Interactive cursor in Matlab plots... - comp.soft-sys.matlab ...Saving graphs with datatips - comp.soft-sys.matlab... a=axes('parent',f); p=plot(a,x,y); %% % add some data cursors before running ... datacursormode and subplot - comp ... programatically determine if scrollbar is visible? - comp.lang ...Hi All, I have a scrollpane with vertical scrollbar set to show as needed (see snippet below). I'm trying to work out a reliable way of determining ... Saving graphs with datatips - Newsreader - MATLAB CentralFile exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community Saving graphs with datatips - comp.soft-sys.matlab | Computer GroupOn 11-01-13 01:06 PM, Andy wrote: > I'm currently using the following code to save a graph: > > g=figure; > p=copyobj(myAxes,g); > set(p,'Units','normalized ... 7/25/2012 4:20:44 AM
|