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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 need help creating and editing a lot of graphs
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Peter Roosjen

13 Posts

Posted - 02/10/2012 :  08:45:52 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: 8.5.0 SR 1
Operating System: Win 7 Ultimate x64

Hello,

I'm a remote sensing student and I'm trying to use Origin pro to map hyper spectral data which was acquired by measuring an object under several different viewing angles. I have the data of the measurements stored in a table with in the first and second column the theta(x) and r(y) values (I want to display the my results in a polar contour graph). At each measuring angle, the ASD has taken 2150 measurements, at wavelengths between 350nm to 2500nm at a 1nm interval. For each wavelength I would like to create a polar contour graph. This means that I will have to make 2150 different graphs.

My questions is: is there a way to do this without making 2150 individual graphs? I only seem to be able to create a restricted number of graphs at the same time. The method Ive tried before was: selecting the theta(x) and r(y) columns, together with a number of columns which contain my measurement values. All the my data will be drawn into a single graph, and then by extract to layers and extract to graphs I get individual graphs. Here Im only able to make a restricted number of graphs at the time, since I am not able to load all my measurements into a workbook. Also I cant seem to find the right settings in order to fit the graphs in the new graph screens.

Also Im not able to adjust all the graphs at once: I would like to edit one graph, and apply all the changes to all the graphs. By editing I mean: changing the colour scheme, changing the number of classes, changing the position of the title of the graphs, ect.

Can anyone help me?

Thanks for your efforts!

Hideo Fujii

USA
1582 Posts

Posted - 02/10/2012 :  1:07:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Peter,

Once you import all data in a single worksheet (X in 1st col, Y in 2nd col, 
and Z in the rest), you can run the following script to plot all Z column 
as a polar contour:

//////////////////////////
%K=%H;
nc=wks.ncols;
for(ii=3; ii<=nc; ii++) {
  window -a %K;
  wks.col$(ii).type=6; //set to Z
  wks.colSel($(ii),1); //activate the col
  worksheet -p 243 PolarContour;  //plot
  layer.x.to=360;  //show 360degree
  window -ch 1;  //hide
};
////////////////////////////

This code designates Z to the 3+ columns, so no need to designate by your self.
To save memory, I hide all plots. Also, when you import the data, I suggest 
not to add sparklines (in the import option). 

Do you think it works?

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 02/10/2012 1:16:22 PM
Go to Top of Page

Peter Roosjen

13 Posts

Posted - 02/10/2012 :  4:00:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Hideo Fujii!

That works for drawing the graphs! I'm only able to copy - paste 250 columns in my worksheet, so I am not able to draw all the 2150 graphs at once. But this already saves me a lot of time!

Now I would also like to edit all the graphs: the legend by default ranges from red (low z-values) to blue (high z-values) in a rainbow colour scheme and I would like to have that the other way around (from blue to red) and also in a bit more classes (by default it seems to be 8 classes and I would prefer 15 or 20). There also appears to be no title in the graphs (I have the names of in the 'Long name' row, but they are not in the graphs). Is there an automated way to do these things as well? Also, can I also automatically save the graphs (as for example .gif)?

And a final thing: Can you tell me what type of interpolation is applied to create the polar plots?

Thank you very much already for your time!
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 02/10/2012 :  4:48:47 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Peter,

> I'm only able to copy - paste 250 columns in my worksheet

I would first like to solve this issue because I thought your data are obtained in a worksheet by importing from external files using the "Start New Columns" option for the Import Mode of Multiple ASCII import. You could only get 250 columns because actually of the copy-and-paste operation? Could you please explain how you get your data into worksheet?

By the way, XYZ contour in Origin uses B-Spline for smoothing according to:
http://www.originlab.com/www/helponline/Origin/en/UserGuide/Creating_Contour_Graphs.html#Algorithm_for_Creating_a_Contour_from_a_Worksheet

though in your case, the coordinates conversion between Cartesian and Polar should be involved.

--Hideo Fujii
OriginLab

P.S. My colleague told me that in Origin 8.5 if you copy-and-paste from Excel to Origin, the maximum number of columns are limited to 256. This has been fixed in ver. 8.5.1. If this is your case, you can try the evaluation version of Origin 8.6;

Edited by - Hideo Fujii on 02/10/2012 5:19:20 PM
Go to Top of Page

Peter Roosjen

13 Posts

Posted - 02/10/2012 :  6:20:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hideo Fujii,

Thank you for your fast reply!
I have my data stored in an excel file. I have opened this file in Orgin by File -> Open Excel. Here I selected all rows and columns and copied them to a new worksheet. In the new worksheet there are 2 columns by default (x and y). I just paste my data in the first cell and then the worksheet gets filled up untill column 248.

I will try to install the 8.6 evaluation version to see if that will take care of this problem.
Go to Top of Page

Peter Roosjen

13 Posts

Posted - 02/10/2012 :  6:53:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have installed the 8.6 version and now I am able to copy - paste all my columns into a worksheet, so that problem is solved!
Go to Top of Page

Peter Roosjen

13 Posts

Posted - 02/13/2012 :  05:02:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Unfortunately the hide option does not seem to work anymore. All the graphs are drawn into a new window. Also the computation time takes quite a long: 20 seconds per graph, and after 20 30 graphs, the program crashes..
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 02/13/2012 :  12:33:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Peter Roosjen,

Here, we couldn't reproduce the crash. So, could you please send your Origin 
file to us, so that our developers can look at the problem? 
(http://www.originlab.com/index.aspx?go=Support&pid=752)

Also, could you please tell us which operating system (32bit or 64bit?) 
you are using.

Thank you!

--Hideo Fujii
OriginLab


Edited by - Hideo Fujii on 02/13/2012 2:59:16 PM
Go to Top of Page

Peter Roosjen

13 Posts

Posted - 02/13/2012 :  2:56:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I've tried the other script as well, but that gives the same result: the graphs are drawn in a new window and the program crashes after a few graphs are drawn. I used the 64bit version.

After have a look at my data I found that there are a lot of columns which are not useful for me. Therefore it is not necessary the draw all the 2150 graphs. So I will be fine by using your script in the 8.5 version and only draw 250 graphs.

Now I would like to edit my graphs, and hopeful it is also possible by running a script.

The default graph I get after running the script is:



But what I would like is:



- A 90 rotation of the axes
- 15 classes (from min to max value), with an inverse colour scheme
- A title (which changes per graph)
- Projection of my data points (preferably on top of the data and axis)
- No scale bar

After this, I would like to save all graphs as separate files (.jpg). Can both the editing and saving processes be automatized as well?

Thank you!

ps. I will send you my datasheet.

Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 02/13/2012 :  6:05:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Peter Roosjen,

> ps. I will send you my datasheet.
Thank you very much for the data, and on my machine I could reproduced the problem as the sample script (original) crashed after 332 graphs are created. We are looking at the problem.

Regarding the customization such as the direction of the rotation, etc, you can save an already customized graph as a new template (saved in your User Files Folder) with a new given name - say, myPolarContour.
Then, when you run the script, you can modify the 7th line to:

  worksheet -p 243 myPolarContour; //plot

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 02/13/2012 6:07:17 PM
Go to Top of Page

Peter Roosjen

13 Posts

Posted - 02/14/2012 :  05:12:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Creating a template for my graphs works, but still I can't get everything the way I want:

I create a title for each graph by adding this line to my script:
label -s $(350+ii-3);
It works fine for creating the right title, but can you please tell me how to set the position where my title appears in the graphs?

Another thing is that I can't find a way to project my data points in the graphs. Is there also a script which draws all my data points in the graphs?

Thanks again!

Peter



Edited by - Peter Roosjen on 02/15/2012 09:06:17 AM
Go to Top of Page

easwar

USA
1964 Posts

Posted - 02/15/2012 :  12:37:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Peter,

To create graphs from a custom template, please try this code instead:


// Declare range to point to current data sheet
range rsheet = !;
// Get number of columns in the book
int nc = wks.ncols;

// Loop over all columns from the third column onwards
for(int ii=3; ii<=nc; ii++)
{
	// Declare range to point to the column
	range rc = rsheet!$(ii);
	// Set column as type Z
	rc.type = 6;
	// Create a new graph using custom template
	win -t p MyPolarC;
	// Move data column into graph layer
	layer -i rc;
	// Hide the graph window
	window -ch 1;
}


I was able to create all 2150 graphs this way using the data you sent us, there was no crash, all graphs were created hidden. I was able to save the opj and re-open etc. I used the 64-bit version of 8.6SR1.

Note that in the above, I am using a custom template called "MyPolarC" which I had customized and saved, starting from the standard polar contour template. I customized to include the rotation you wanted, the color scheme, the display of points etc, and all properties were remembered when using this way of creating the graph using "win -t plot" and then moving the data into the empty graph layer.

As for the graph label issue, originally you wanted to refer to the long name of the column in your label, which contained the desired number you wanted to display. To do this, add a label in your custom template anywhere you want, and for the label text, type this:
%(1,@LL)
You can put other text before and after this syntax as you desire. Then click outside the text label, right click on the label, and select "Programming Control" from the context menu. In that dialog, change the "Link to (%...." drop-down to 1. This tells Origin to interpret that syntax and use the long name. Then when you use the template with another column, the long name of that new column will be displayed.

To see other possible notations, refer to:
http://wiki.originlab.com/~originla/ltwiki/index.php?title=LabTalk:Text_Label_Options
which is also in your LabTalk help file.

If you want to instead use the "label -l" command, look up "label -p" which allows you to place the label at a certain position, and there are other options for the label command.

Easwar
OriginLab


Go to Top of Page

easwar

USA
1964 Posts

Posted - 02/15/2012 :  12:55:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Peter,

You had also mentioned the need to export all the graphs. For that you can use the "expGraph" X-Function, you can look up help on that, and include that in the loop.

If your intent is to just export, and you don't need to keep the graph, you could delete the window after exporting, inside the loop.

So you could modify the code inside the loop such as below:


...
...
	win -t p MyPolarC;
	// Move data column into graph layer
	layer -i rc;
	// Export as png with width of 1000 pixels
	string strFileName$ = "MyExport" + rc[L]$;
	expGraph -sb type:=png path:= "c:\temp" filename:= strFileName$ tr1.width:=1000 tr1.unit:=2; 
	// Delete the graph
	win -c;
}


Easwar
OriginLab
Go to Top of Page

Peter Roosjen

13 Posts

Posted - 02/15/2012 :  3:07:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Easwar,

I cannot find the "Link to (%...." -> drop-down to 1. I now used these settings:

Is this correct?

Also when I run this script:

range rsheet = !; 
int nc = wks.ncols; 

for(int ii=3; ii<=nc; ii++) 
{
	range rc = rsheet!$(ii); 
	rc.type = 6; 
	win -t p BMyPolarC; 
	layer -i rc; // Move data column into graph layer
	string strFileName$ = "MyExport" + rc[L]$;
	expGraph -sb type:=jpg path:= "c:\temp" filename:= strFileName$ tr1.width:=1000 tr1.unit:=2; 
	win -c; 
}

I get this error:
"MyExport" + rc[L]$
string expression error!
STRFILENAME:failed to add variable to local stack!
#Command Error!

Do you have any idea what I'm doing wrong?

Thank you!

Peter

Go to Top of Page

easwar

USA
1964 Posts

Posted - 02/15/2012 :  3:22:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Peter,

Are you using the latest 8.6 SR1 version? Earlier in the thread you had mentioned you switched to 8.6.

Can you tell us the exact version? Go to Help->About Origin, and tell us what you see there including the build number (the first two lines).

From the screen shot you pasted, looks like now you are trying in an older version? Then the script also may not work as I had posted, as some of the statements may be specific to latest version.

Can you try in 8.6 SR1?

Easwar
OriginLab

Go to Top of Page

Peter Roosjen

13 Posts

Posted - 02/15/2012 :  4:53:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Easwar

I've tried the following script in the 8.6 sr1 eva version on a win7 Ultimate x64 pc:

range rsheet = !;
int nc = wks.ncols;


for(int ii=3; ii<=nc; ii++)
{
	range rc = rsheet!$(ii);
	rc.type = 6;
	win -t p MyPolarC;
	layer -i rc;
	string strFileName$ = "MyExport" + rc[L]$;
	expGraph -sb type:=png path:= "c:\temp" filename:= strFileName$ tr1.width:=1000 tr1.unit:=2; 
	win -c;
}


When I run it nothing happens. Also no error messages.
Do you see what goes wrong?

Thank you!

Peter
Go to Top of Page

easwar

USA
1964 Posts

Posted - 02/15/2012 :  4:59:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Peter,

This works on 86 SR1 on multiple machines at our end.

Did you have the worksheet with your data as the active window when running the code? the code assumes worksheet is active.

You can add type statements in the code to check things...in other words try debugging the code. You can start with as smaller count in the loop such as not go all the way to nc, but say do ii=3 to 7 or something like that to debug.

Easwar
OriginLab

P.S. Also, when it runs successfully, you we see nothing in the interface, as the graphs are created hidden, then exported, then deleted. So look in the folder to see if you got your exported jpg files! In the code I was placing the exported files to c:\temp. Change that to a directory that exists in your system, so please check and change such things in the script as it applies to your system.
Go to Top of Page

Peter Roosjen

13 Posts

Posted - 02/15/2012 :  5:08:19 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I've imported a .xlsx file which contains my data into Origin by File -> Import -> Excel. In the next screen I apply the settings which make sure that column 1 and 2 contain my theta and radius, and that the Long Name row contains my titles.

After this I created my graph template and tried to run the script.

How can I check whether my data sheet is active or not?
Go to Top of Page

Peter Roosjen

13 Posts

Posted - 02/15/2012 :  5:17:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I've tried it again and after a couple of times it finally worked. But now my graphs look like this:



It doesn't seem to apply my template..
Go to Top of Page

Peter Roosjen

13 Posts

Posted - 02/15/2012 :  5:29:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Okay, I probably did something wrong. It works perfectly now!

Thank you very much!!

Is there also a way to make this script work in 8.5?

Peter
Go to Top of Page

easwar

USA
1964 Posts

Posted - 02/15/2012 :  9:45:47 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by Peter Roosjen

Okay, I probably did something wrong. It works perfectly now!

Thank you very much!!

Is there also a way to make this script work in 8.5?

Peter



Hi Peter,

The following should work in 8.5 (I did not have 8.5 handy, tried in a version closer to it....).

Of course please consider upgrading to 8.6!
You can watch this movie to see what is new in 8.6:
http://originlab.com/index.aspx?go=Support/VideoTutorials&pid=1826

Easwar
OriginLab



// Get number of columns in the book
int nc = wks.ncols;

// Loop over all columns from the third column onwards
for(int ii=3; ii<=5; ii++)
{
	// Declare range to point to the column
	range rc = $(ii);
	// Set column as type Z
	rc.type = 6;
	// Create a new graph using custom template
	win -t p MyPolarC;
	// Move data column into graph layer
	layer -i rc;
	// Export as png with width of 1000 pixels
	string strFileName$;
	strFileName$ = "MyExport"+rc[L]$;
	expGraph -sb type:=png path:= "c:\temp" filename:= strFileName$ tr1.width:=1000 tr1.unit:=2; 
	// Delete the graph
	win -c;
}


Go to Top of Page

cpyang

USA
1406 Posts

Posted - 02/15/2012 :  10:25:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Looks like there was a bug in Origin 8.5 such that

"MyExport" + rc[L]$;

will not work, so you must remove the space before and after the + sign, to write as


"MyExport"+rc[L]$;



CP

Go to Top of Page

Peter Roosjen

13 Posts

Posted - 03/04/2012 :  3:24:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry for my late reaction. It works perfect! Thank you very much!

I still have one last small question concerning the range of my data. I try to get a fixed range for my legend (the same range for all my graphs). I try to achieve this by applying the following and saving a template afterwards:



However, when I run the script, the range of the legends in all the graphs is set to the min and max values of my data. How can I apply a fixed min, max and increment value for the legends of all my graphs?
Go to Top of Page

easwar

USA
1964 Posts

Posted - 03/04/2012 :  8:50:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Peter,

After customizing your levels, on the Colormap/Contours tab of Plot Details, change the "Rescale Mode" drop-down to "Manual" and then re-save your template. The default of "Normal" means the levels will rescale when data changes. When set to "Manual" the levels will not change.

Easwar
OriginLab
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000