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
 Why colourmap for the second group not work
 New Topic  Reply to Topic
 Printer Friendly
Author  Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

leoxiong

China
2 Posts

Posted - 11/25/2025 :  8:55:27 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I used Python to plot two sets of data. Both underwent grouping operations followed by colormap application. However, only the first set's colors take effect. Regardless of which set is placed first, the second set's colors consistently appear black.
When opening Origin's plot properties under the Group tab, the symbol edge color fails to display correctly. The “Increment” setting is set to “Individual,” with the default being “None.” Why is this happening?

https://my.originlab.com/ftp/forum_and_kbase/Images/err_data.zip

----------------------------------------------
import os
import pandas as pd
import originpro as op


def plot_excel_sheets(excel_path):
book_name = os.path.splitext(os.path.basename(excel_path))[0]
wb = op.new_book('w', book_name)

xls = pd.ExcelFile(excel_path)
for s_name in xls.sheet_names:
df = xls.parse(s_name)
if df.empty:
continue

X = df.iloc[:, 0]
y_cols = df.iloc[:, 1:]
n_y = y_cols.shape[1]
if n_y == 0:
continue
headers = y_cols.columns.tolist()

wks = wb.add_sheet(s_name)
wks.from_list(0, X, lname='pd')
for i, h in enumerate(headers, 1):
wks.from_list(i, y_cols.iloc[:, i-1], lname=h)

graph = op.new_graph(lname=book_name+"_"+s_name)
gl = graph[0]

half = n_y // 2
# line
if half:
line_rng = f'[{book_name}]{s_name}!(A,B:{half+1})'
plot = gl.add_plot(line_rng, type='l')
gl.group(True, 0, half-1)
plot.set_cmd('-w 1500')
plot.colormap = 'Color4Line'

# scatter
if n_y > half:
scat_rng = f'[{book_name}]{s_name}!(A,{half+2}:{n_y+1})'
plot = gl.add_plot(scat_rng, type='s')
gl.group(True, half, n_y-1)
plot.set_cmd('-z 9')
#plot.set_cmd('-z 9','-csem Color4Line')
plot.colormap = 'Color4Line'

gl.rescale()


if __name__ == '__main__':
EXCEL_FILE = r'C:\Users\DELL\Desktop\example.xlsx'
plot_excel_sheets(EXCEL_FILE)

ChaoC

USA
216 Posts

Posted - 11/26/2025 :  1:41:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

You can take the graph you created with this code, open the Plot Details tab, and go to the 'Group' tab for the second group. For 'Symbol Edge Color', set the increment to "By One".
Right-click the graph title bar and select 'Save Template As', give it a name, and save it.

Then change your code to use the template for the graph:

graph = op.new_graph(lname=book_name+"_"+s_name, template=r'C:\your\filepath\templatename.otpu')

Rerun the code. It should now follow the colormap you've used.

Best,
Chao
Go to Top of Page
   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