The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 inserting graph

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
ovince Posted - 10/09/2006 : 12:14:08 PM
Hi All,

Is there any good example how to insert one graph into another? Forum Search does not provide it.

thanks
Oliver
5   L A T E S T    R E P L I E S    (Newest First)
zachary_origin Posted - 10/11/2006 : 11:43:14 AM
Hi Oliver,

Ok, I realized the problem. The reason for the result you got is that when using the line gpDest.AppendLayers("origin"); to add a new layer, a template "origin" is used. So in the new layer, the graph is plotted in the style of that template, e.g. the column bar is changed to line, x scale is changed to 0-10. To set it be as same as the source graph, we need use gpDest.AppendLayers("Column"); to add layer, and after the graph is copied, the scale of the axis should also be adjusted in accord with the original one. These will be alot troublesome. So I think it would be better plot the graph directly the destination layer rather than first plot it in another graph page and then copy it to the destination graph.


Zachary
OriginLab Technical Services.


Edited by - zachary_origin on 10/11/2006 11:51:02 AM
ovince Posted - 10/10/2006 : 04:04:34 AM
hi

Yes it works but I obtain this



1.
That is, the x range of the histogram is changed (0-0.5 initially to 0-10 in the inset graph ). Consequently, the histogram in the inset graph is shrinked (I hope only shrinked; I can't zoom it enough to be able to see what happend )

2.
The legend of the histogram also changed his form and content.

Any idea why?

oliver
zachary_origin Posted - 10/10/2006 : 03:43:23 AM
Hi Oliver,

I got the problem. It is because before running the function, the source graph (Graph1) is active, then the LabTalk scipt in the function takes efforts in the source graph rather than the destination graph (Graph2). If you active the destination graph, it will work. Therefore, we need add a line
set_active_layer(glDestNew); 
right before the last line of in the function. Try it.


Zachary
OriginLab Technical Services.

Edited by - zachary_origin on 10/10/2006 03:52:00 AM
ovince Posted - 10/10/2006 : 02:16:50 AM
hi Zachary,

Thanks for code.


I dont know where it goes wrong but I have something like this:

Before using 'void Add_Inset_Graph()'




After using 'void Add_Inset_Graph()'





Graph2 has only 1 layer. What might be the reason for this failor?

Thanks
oliver
zachary_origin Posted - 10/10/2006 : 12:22:47 AM
Did you mean adding a inset to a graph. If it is, here just give a brief example:



void Add_Inset_Graph()
{
//Graph1 is the source graph
//maybe there are more than one layer in the graph.
//if it is, you need a loop to get all the layers

GraphLayer glSource("Graph1", 0);
//Graph2 is the destination graph
GraphPage gpDest("Graph2");

//add a new layer to hold the source graph
gpDest.AppendLayers("origin");
GraphLayer glDestNew = gpDest.Layers(gpDest.Layers.Count()-1);

//get the data plots from the source graph,
for(int nPlot=0; nPlot<glSource.DataPlots.Count(); nPlot++)
{
DataPlot dpSource = glSource.DataPlots(nPlot);

//In ver7.5, GraphLayer::AddPlot() only supports Curve as parameter, so need get the Curve from DataPlot
Curve crv(dpSource);
int nRes = glDestNew.AddPlot(crv);
}

//Using LabTalk script to control the positon of the layer
LT_execute("layer 20 20 40 5;");
}



Zachary
OriginLab Technical Services.


Edited by - zachary_origin on 10/10/2006 12:26:58 AM

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000