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
 Change x-column for entire graph
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

terra_42

Austria
6 Posts

Posted - 02/12/2024 :  04:00:42 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello community,

recently I found a mistake in my Origin-file. I set up a line graph from my project data, but instead of selecting my first data column as x-axis, I selected Origin's Auto option. Since the data column doesn't go in integer steps (0,1,2,3...) it contains smaller steps (0; 0,125; 0,25...). I know that there is an "replace"-option at the setup diagram panel for one single line, but there is a lot of data, where I need to replace the x-axis. Is there any way to replace the x-selection for an entire diagram and not just for one single data row?

Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2023b (64-bit) SR1, 10.0.5.157 (Studentenversion)
Operating System: x64-system, windows11

YimingChen

1594 Posts

Posted - 02/12/2024 :  08:43:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Are you trying to plot multiple y columns against the row indices(Auto option for x)? If so, you can use Plot Setup. Without selecting any columns, go to menu Plot->Basic 2D->Line. Check the boxes shown below.


James
Go to Top of Page

terra_42

Austria
6 Posts

Posted - 02/12/2024 :  09:16:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi James,

I have a plot with 2 layers. When I selected the data for these layers, I clicked on Auto option for the x-axis and selected a couple of columns from my data for y. Then I realized, I needed column A as x-axis instead of the Auto option. I already figured out, how to manually change the x-axis source within the plot setup menu.
As you can see in the first picture, when I select one of the row, I can untick the Auto option in X and set a different column (red tick) and hit "replace" (circled in red). But when I select multiple rows, the "replace" button is no longer usable (shown in the second picture, circled in red).



What I want to do is pretty much, what shows the second picture: select multiple data rows, change in the X column from "<Auto X>" to column A (that has my actual x-values) and hit replace. Do you know, how to do that for multiple plots?

Carina
Go to Top of Page

YimingChen

1594 Posts

Posted - 02/12/2024 :  09:43:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Could you add multiple columns to the group, then remove the unwanted columns from the group?
Go to Top of Page

YimingChen

1594 Posts

Posted - 02/12/2024 :  10:50:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Another option is to run the script below. Please select menu Window->Script Window with the graph activated, then copy and paste the script below to the window. Select all lines and press Enter key to
execute. The script should change the x's of all plots on the graph to Col(A). See if it works.

doc -e DY {
	string strRange = %C;
	string strBook = strRange.GetToken(1,"_")$;
	int nplot = layer.plot;
	layer -cx %(strBook$)_a $(nplot);
}


James
Go to Top of Page

terra_42

Austria
6 Posts

Posted - 02/12/2024 :  11:30:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The code works for one layer of the plot, but not for the other. My two plots get their data from different worksheets (e.g layer 1 from worksheet A and layer 2 from worksheet B). The script is great for layer 2, it changes all the <Auto X> to column A from worksheet B. That happens for layer 1 as well. So now I've got worksheet B as data source for layer 1 and 2. Is there any way to automatically use the worksheet, where the original data was from? Like
Layer 1 data is in worksheet A, so use column A of worksheet A
Layer 2 data is in worksheet B, so use column B of worksheet B etc.

Thank you for your time!
Carina
Go to Top of Page

YimingChen

1594 Posts

Posted - 02/12/2024 :  3:19:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Try the script below:

doc -e lp {
	doc -e D {
	string strRange = %C;
	string strBook = strRange.GetToken(1,"_")$;
	string strSheetIndex = strRange.GetToken(2,"@")$;
	int nplot = layer.plot;
	if (strSheetIndex$ != "") {
			layer -cx %(strBook$)_B@%(strSheetIndex$) $(nplot);
		} else {
			layer -cx %(strBook$)_A $(nplot);
		}
	}
}




quote:
Originally posted by terra_42

The code works for one layer of the plot, but not for the other. My two plots get their data from different worksheets (e.g layer 1 from worksheet A and layer 2 from worksheet B). The script is great for layer 2, it changes all the <Auto X> to column A from worksheet B. That happens for layer 1 as well. So now I've got worksheet B as data source for layer 1 and 2. Is there any way to automatically use the worksheet, where the original data was from? Like
Layer 1 data is in worksheet A, so use column A of worksheet A
Layer 2 data is in worksheet B, so use column B of worksheet B etc.

Thank you for your time!
Carina

Go to Top of Page

terra_42

Austria
6 Posts

Posted - 02/13/2024 :  02:04:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi James,
thank you so much for you time! It's peculiar, on some graphs it works for the first layer but not the second one and on some graphs it doesn't work at all. I think I'll replace what works with your code and do the rest manually. I helps a lot, even if it doesn't work with all graphs and all layers. If you have further suggestions, of course I'd be happy.
Thanks, Carina

quote:
Originally posted by terra_42

The code works for one layer of the plot, but not for the other. My two plots get their data from different worksheets (e.g layer 1 from worksheet A and layer 2 from worksheet B). The script is great for layer 2, it changes all the <Auto X> to column A from worksheet B. That happens for layer 1 as well. So now I've got worksheet B as data source for layer 1 and 2. Is there any way to automatically use the worksheet, where the original data was from? Like
Layer 1 data is in worksheet A, so use column A of worksheet A
Layer 2 data is in worksheet B, so use column B of worksheet B etc.

Thank you for your time!
Carina


[/quote]
Go to Top of Page

YimingChen

1594 Posts

Posted - 02/13/2024 :  08:58:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you'd like, you can share the project along with any graphs that failed. I'd be happy to help troubleshoot.

James
Go to Top of Page

terra_42

Austria
6 Posts

Posted - 02/13/2024 :  09:32:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
https://my.originlab.com/ftp/forum_and_kbase/Images/troubleshoot.opju
Attached you'll find a simplyfied version of the project. The graphs are already set to column A (Frequenz) since I changed some of them manually. But basically when I tried your code on one of the graphs, layer 1 worked well, but layer 2 didn't change from Auto to column A "Frequenz". Everything else is supposed to stay the same (worksheet and the y-axis data selection is correct), only the tick in X needs to be changed from <Auto> to column A (Frequenz") for all graphs and all layers. I wouldn't mind executing the code for each graph and layer seperately, if it would do the trick for all the data that the layer contains. Sorry, I'm not really of help since I haven't coded in Origin whatsoever so far. I'll look into it in the future, but I'd really appreciate your help for this file. :)
Thanks again! ~ Carina
Go to Top of Page

YimingChen

1594 Posts

Posted - 02/13/2024 :  10:16:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In your earlier post, you mentioned
"Layer 1 data is in worksheet A, so use column A of worksheet A
Layer 2 data is in worksheet B, so use column B of worksheet B etc."

However, it seems that you want to change x to col(A) of the sheet where the plotted data originates. If so, please try the following script:

doc -e lw {
	doc -e D {
	int nplot = layer.plot;
	range rx= [%(1,@W)]%(1,@WS)!1;
	layer -cx rx $(nplot);
	}
}


James
Go to Top of Page

terra_42

Austria
6 Posts

Posted - 02/13/2024 :  10:45:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That works perfectly! Thank you so much! It will save so much time, going through my old projects and if that mistake happens again :)
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