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 for Programming
 Forum for Python
 How to generate stacked column plot?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ChemistryGuy

Australia
49 Posts

Posted - 03/01/2023 :  6:18:41 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2023 (64-bit) Beta7
Operating System: Windows 11

I am trying to use Python to generate a stacked column (aka stacked bar) graph, using a template I have made. However, I am having trouble working out the correct way to import the data to accomplish this.

If I use Code Sample 1 (shown below), the two columns are plotted superimposed on each other (rather than stacked). If I use Code Sample 2 (shown below) the two columns are plotted side-by-side rather than stacked.

If anyone knows how to do this such that the columns appear stacked, please would you advise me?

Code Sample 1
gl.add_plot(data_wks, coly=1, colx=0, type='?')
gl.add_plot(data_wks, coly=2, colx=0, type='?')

Code Sample 2
gl.add_plot(data_wks, coly=1, colx=0, type='?')
gl.add_plot(data_wks, coly=2, colx=0, type='?')
gl.group(True, 0, 1)

YimingChen

1617 Posts

Posted - 03/02/2023 :  11:56:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Could you add one line after code sample 2 to set the plots to stack cumulatively?
op.lt_exec('layer -b s 1')


James
Go to Top of Page

ChemistryGuy

Australia
49 Posts

Posted - 03/02/2023 :  5:51:06 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I gave this a try and it worked perfectly, thank you very much!

Also, in case it helps anyone else, the code that worked for me was slightly different to that which was provided:

gl.lt_exec('layer -b s 1')
Go to Top of Page

ChemistryGuy

Australia
49 Posts

Posted - 03/15/2023 :  04:54:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
A follow up question: Is it possible to change the column spacing using Python?
Go to Top of Page

kartridzhej

0 Posts

Posted - 03/15/2023 :  05:35:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
A follow up question: Is it possible to change the column spacing using Python?
Go to Top of Page

YimingChen

1617 Posts

Posted - 03/15/2023 :  11:17:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
gl.lt_exec('set %C -vg 40')

Here 40 is the percentage gap.

James

Edited by - YimingChen on 03/15/2023 11:17:50 AM
Go to Top of Page

ChemistryGuy

Australia
49 Posts

Posted - 03/17/2023 :  4:39:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much, I tried this and it worked perfectly!
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