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
 Need help with setting line color and using specif
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

pavi-chem

United Kingdom
26 Posts

Posted - 06/01/2023 :  09:09:25 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

YimingChen

1618 Posts

Posted - 06/01/2023 :  2:19:12 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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