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
 Need help with setting line color and using specif

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
pavi-chem Posted - 06/01/2023 : 09:09:25 AM
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System:win10

How can I set the line color for a Plot object in the originpro module? I tried using plot.line.color, but it resulted in an AttributeError: 'Plot' object has no attribute 'line'.

I am encountering an AttributeError: module 'originpro' has no attribute 'SetLineColor' when trying to use the SetLineColor function from the originpro module. How can I resolve this issue?

I'm trying to set the line color to black using op.color('black'), but I get an AttributeError: module 'originpro' has no attribute 'color'. What is the correct way to specify the color in the originpro module?

code:
import originpro as op
import os
import tkinter as tk
from tkinter import filedialog

# Very useful, especially during development, when you are
# liable to have a few uncaught exceptions.
# Ensures that the Origin instance gets shut down properly.
# Note: only applicable to external Python.
import sys


def origin_shutdown_exception_hook(exctype, value, traceback):
"""Ensures Origin gets shut down if an uncaught exception"""
op.exit()
sys.__excepthook__(exctype, value, traceback)


sys.excepthook = origin_shutdown_exception_hook

# Only run if external Python
if op.oext:
op.set_show(True)

# Prompt user to select an XLSX file for the second graph
xlsx_file_path = filedialog.askopenfilename(title="Select XLSX File for Graph 2", filetypes=[("XLSX Files", "*.xlsx")])

# Load the XLSX file into a new worksheet
wks2 = op.new_sheet()
wks2.from_file(xlsx_file_path, False)

# Create a graph page with the glWater3D template
graph = op.new_graph(template='glWater3D')
gl = graph[0]

# Define the range of columns (1-12) for the y-axis
y_columns = list(range(1, 13)) # Adjust the range as needed

for col in y_columns:
plot = gl.add_plot(wks2, 0, col, col+1)
# Set line color to black
plot.line.color = op.ocolor('black')
# Set fill color to white
plot.fill_color = op.ocolor('white')

# Group and Rescale the graph
gl.group()
gl.rescale()

# Tile all windows
op.lt_exec('win-s T')

# Prompt user for the output Origin file name
root = tk.Tk()
root.withdraw()
output_file_path = filedialog.asksaveasfilename(title="Save Output Origin File", filetypes=[("Origin Project Files", "*.opju")])

# Save the project to the specified output file path using both op.oext and op.save
if op.oext:
op.save(os.path.abspath(output_file_path))


Thanks a bunch!
Pavi.
1   L A T E S T    R E P L I E S    (Newest First)
YimingChen Posted - 06/01/2023 : 2:19:12 PM
You can try:
plot.color = op.ocolor('Black')


But don't group the plots. Remove the line below otherwise a color list will be applied to the group.
gl.group()


James

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