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
 Colormap not updating for palette
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

daanwielens

Netherlands
6 Posts

Posted - 10/21/2022 :  06:08:45 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver: 2022 SR1
Operating System: Win 10
-------------------------------------------------------
Hi, I'm trying to create a plot with grouped data and then apply a color palette (rainbow) to it (with increment binned/stretched). I fail at the first step, i.e. selecting the colormap. When I select a increment list ('Candy', 'Fire', 'Classic') the colors of the plot (plot.colormap) do change, but if I select any color palette ('Rainbow.pal', 'Maple.pal') the color of the plot doesn't change. According to the documentation of originpro.graph.Plot.colormap this should be working.

Code used:

import originpro as op

# Start a new origin project
op.new()

# Choose whether Origin should be visible or not (default = True)
op.set_show(True)

# Create grouped data set
x = np.linspace(0, 10, 501)
y1 = np.sin(x)
y2 = np.sin(x+0.1)
y3 = np.sin(x+0.2)
y4 = np.sin(x+0.3)
y5 = np.sin(x+0.4)

# Create a new worksheet in writing mode
wks = op.new_sheet('w')

# Add data to the worksheet
wks.from_list(0, x)
wks.from_list(1, y1)
wks.from_list(2, y2)
wks.from_list(3, y3)
wks.from_list(4, y4)
wks.from_list(5, y5)

# Create a figure
gp = op.new_graph()       # Create a graph object
gl = gp[0]                # Select the first layer
# Plot entire worksheet
plot = gl.add_plot(f'{wks.lt_range()}!(?,1:end)')
# Group the plots
gl.group()
plot.colormap = 'Rainbow.pal'
gl.rescale()

YimingChen

1618 Posts

Posted - 10/21/2022 :  10:40:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You need to plot 3D surface or contour to set the colormap to color palette. See the example:
https://www.originlab.com/doc/en/python/Examples/Graphing#Plot_Contour_and_3D_Surface_Graph

James
Go to Top of Page

daanwielens

Netherlands
6 Posts

Posted - 10/21/2022 :  11:02:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi James,

Thanks for your reply. What I try the replicate is outlined in the figure below: change the line color increment to 'Binned', then 'Load palette' and select 'Rainbow' (but then via Python). Is this possible?

Thanks!

Go to Top of Page

minimax

351 Posts

Posted - 10/24/2022 :  05:29:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It seems that command plot.colormap failed to apply colors to a set of grouped plots from palette file.

We will try to fix it shortly. (internal bug track id: ORG-25825)

PS, to set as 'Binned' increment mode, you need to call
plot.colorinc=3


Go to Top of Page

daanwielens

Netherlands
6 Posts

Posted - 10/27/2022 :  05:02:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi minimax,

Thanks for the reply. Will you report back here when the bug is fixed, or can I follow the issue on another platform? Thanks!
Go to Top of Page

minimax

351 Posts

Posted - 10/27/2022 :  10:50:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes, I will update you here when the bug is fixed.
Go to Top of Page

minimax

351 Posts

Posted - 11/03/2022 :  11:27:38 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi daanwielens,

The problem should have been fixed with originpro >= 1.1.3, but it also requires changes on Origin side.

i.e. you need to upgrade to Origin 2023 to get it work.
Go to Top of Page

daanwielens

Netherlands
6 Posts

Posted - 11/04/2022 :  10:11:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi minimax,

Thanks! I've just upgraded both the python package and Origin itself and it works.
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