Author |
Topic  |
|
sangjung
Korea
2 Posts |
Posted - 06/17/2025 : 01:00:16 AM
|
Origin Ver. and Service Release (Select Help-->About Origin):2024b Operating System: Win10
Hello,
I'm creating an automation tool in Python to generate graphs in OriginLab. I've successfully added a right Y-axis and specified its range. However, I'm unsure how to modify the axis title for this right Y-axis.
======================= import originpro as op import numpy as np
op.set_show(True) book = op.new_book('w', 'MyBook') wks = book.add_sheet('SPACE')
x = np.linspace(0, 10, 100) y1 = np.sin(x) y2 = np.cos(x) + 1
wks.from_list(0, x, 'Time') wks.from_list(1, y1, 'Sin(x)') wks.from_list(2, y2, 'Cos(x)')
graph = op.new_graph() layer1 = graph[0]
plot1 = layer1.add_plot(wks, coly=1, colx=0) plot1.color = (255, 0, 0) plot1.name = 'Sine Curve' layer1.lt_exec(f'set {plot1.name} -w 2000')
layer2 = graph.add_layer(2) # 2: right Y linked X scale plot2 = layer2.add_plot(wks, coly=2, colx=0) plot2.color = (0, 0, 255) plot2.name = 'Cosine Curve' layer2.lt_exec(f'set {plot2.name} -d 2') layer2.lt_exec(f'set {plot2.name} -w 1000')
layer1.rescale() layer2.rescale()
layer1.axis('x').title = 'Transient Time, sec.' layer1.axis('x').limits = (0, 10, 1) layer1.axis('y').title = 'Left value' layer1.axis('y').limits = (-1.0, 1.0, 0.2)
layer2.axis('y').limits = (0, 2.0, 0.2) layer2.axis('y').title = 'Right value'
|
|
YimingChen
1666 Posts |
Posted - 06/17/2025 : 08:59:58 AM
|
It seems the Python code does not support setting the right Y-axis title. As a workaround, you can use LabTalk to set the title. Please replace the last line with:
layer2.lt_exec('label -yr Right value')
James |
 |
|
sangjung
Korea
2 Posts |
Posted - 06/17/2025 : 6:07:36 PM
|
It works !!! Thank you very much ^^ |
 |
|
|
Topic  |
|
|
|