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 Python
 Binding plots to column names

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
Joyserver Posted - 06/28/2021 : 11:24:09 AM
Origin Ver. and Service Release (Select Help-->About Origin): Origin pro 2021
Operating System: Windows 10

Hi,

I am using python code to update a worksheet in Originpro. A graph is made based on some columns in this worksheet. When the number of columns changes, I have found that the graph is not bound to the columns that I want.

For instance, with the first update, there are two columns "width" and "area" (long name in the worksheet). I use column "width" and "area" to draw a scatter plot on the graph and would like the plot to bind with those two columns.

However, with the second update, I receive 3 columns, e.g., "width", "length", "area". Then the scatter plot is not any more based on the column "width" and "area" because the new column "length" disrupts the original order of those two columns. I am wondering whether it is possible to bind plots to columns names, so that, no matter how the columns change in the worksheet, the plot is always made with the assigned column names?

Thanks in advance for your support.
3   L A T E S T    R E P L I E S    (Newest First)
YimingChen Posted - 07/01/2021 : 09:27:38 AM
After you set the column number to 3 by ws.cols=ncol, you need to move the area column to the right by adding a line:
ws.move_cols(1, 1, 1)

The plot on the graph is linked to the column by the internal id of the column instead of the column longname. Hope it is clear.

James
Joyserver Posted - 06/30/2021 : 09:29:33 AM
Hi, James

Please test the following script. example.opju contains a 'BTest' worksheet, in which there are orginally two columns: width and area. I plotted area vs width in a graph 'GTest'. After updating the worksheet 'BTest' with this script, the plot changed to 'length vs width'. However, I still want to keep the original plot of 'area vs width'.

Note that strOriginProject needs to be changed with reference to the opju file on your computer.

import originpro as op
import pandas as pd
strOriginProject='\example.opju'
op.open(strOriginProject)
df_test=pd.DataFrame([[1,2,3],[3,4,5],[7,8,9]],
columns=['width','length','area'])


wb=op.find_book('w','BTest')
ws=wb[0]
ws.clear()

ncol=len(df_test.columns)
ws.cols=ncol
print(ws.cols)
ws.from_df(df_test)
op.save()



quote:
Originally posted by YimingChen

Can you provide the script to show the issue? Especially how you update the worksheet. Thank you.

James

YimingChen Posted - 06/29/2021 : 11:13:53 AM
Can you provide the script to show the issue? Especially how you update the worksheet. Thank you.

James

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