Skip to content

Commit 5f8a170

Browse files
committed
updated readme
1 parent a4b1302 commit 5f8a170

File tree

4 files changed

+78
-39
lines changed

4 files changed

+78
-39
lines changed

README.md

Lines changed: 78 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# PyWrapOrigin
2-
A python wrapper to OriginLab that allows plotting graphs in OriginLab using python.
2+
OriginPro is a graphing and analysis software used by many scientists. Sometimes making many plots by hand can be tedious and is necessary for automation. The OriginPro software is packaged with its own programming languages such as Origin C and LabTalk. But they are difficult for users to learn and implement.
33

4-
The module utilizes Origin C, LabTalk, and OriginExt to enable plotting Origin graphs from the ground up, without relying on making any template.
4+
PyWrapOrigin is a python wrapper to Origin that allows plotting graphs in Origin using python.
55

6-
Manual Installation:
6+
The module utilizes Origin C, LabTalk, and OriginExt to enable plotting Origin graphs from the ground up, without relying on using any template.
7+
8+
Installation:
79
-----
810
Clone the repo:
911

@@ -14,7 +16,7 @@ Clone the repo:
1416
In the cloned directory:
1517

1618
``
17-
python setyp.py sdist
19+
python setup.py sdist
1820
``
1921

2022
``
@@ -23,49 +25,86 @@ Clone the repo:
2325

2426
Usage:
2527
-----
28+
Import Library
2629
```python
27-
import PyWrapOrigin
28-
po = PyWrapOrigin.PyWrapOrigin()
29-
po.connect() #this will open and compile originlab. Also it will compile the originC module.
30-
31-
#to make a new worksheet
32-
ws = po.new_WorkSheet('sheet0','book0')
30+
from PyWrapOrigin.PyWrapOrigin import PyWrapOrigin
3331

34-
#transfer to sheet from a pandas dataframe
32+
```
33+
Connect to Originlab. This will take several seconds to open Origin and import the OriginC code.
34+
```python
35+
pwo = PyWrapOrigin()
36+
pwo.connect()
37+
```
38+
Some arbitrary data in a pandas dataframe to feed into Origin
39+
```python
40+
import numpy as np
41+
import pandas as pd
42+
x1 = np.linspace(0,2)
43+
y1 = np.exp(x1)
44+
y2 = np.exp(2*x1)
45+
46+
data = {
47+
'x1':x1,
48+
'y1':y1,
49+
'y2':y2
50+
}
51+
df = pd.DataFrame(data)
52+
```
53+
Create a new worksheet and send df into Origin
54+
```python
55+
ws = pwo.new_WorkSheet('sheet1','book0')
3556
ws.from_df(df)
36-
37-
#to make a new graph
38-
gp = po.new_GraphPage('Graph1')
39-
40-
#to make new layers
41-
lay1 = gp.new_GraphLayer('right')
42-
lay2 = gp.new_GraphLayer('right')
43-
44-
#to select a layer
57+
```
58+
Create a new graph page
59+
```python
60+
gp = pwo.new_GraphPage('Graph1')
61+
```
62+
A new graph pages already has 1 layer. To add a new layer on the right:
63+
```python
64+
gp.new_GraphLayer('right')
65+
```
66+
The layers can be accessed through the layers attribute of the graph page object.
67+
```python
4568
lay0 = gp.layers[0]
46-
47-
#make a new data plot
48-
dp = lay0.new_DataPlot(ws,0,1,'scatter')
49-
50-
#modify the plot
51-
lay0.y_title('Sine')
69+
lay1 = gp.layers[1]
70+
```
71+
Create new data plots in each layer.
72+
```python
73+
dp0 = lay0.new_DataPlot(ws,0,1,'scatter')
74+
dp1 = lay1.new_DataPlot(ws,0,2,'scatter')
75+
```
76+
Layer and data plot settings.
77+
```python
78+
# Settings of the first layer
79+
lay0.y_title('Exp(x)')
5280
lay0.y_title_size(20)
53-
dp.symb_type(2)
54-
dp.edge_color(0,0,255)
55-
dp.face_color(255,255,255)
56-
57-
#set range
58-
lay0.y_range(-1,1)
59-
60-
#add reflines
61-
lay0.reflines_ver([2,6,9])
81+
lay0.x_title('x')
82+
lay0.x_title_size(20)
83+
# first data plot
84+
dp0.symb_type(2) #circle
85+
dp0.edge_color(0,0,255) #RGB
86+
dp0.face_color(255,255,255) #RGB
87+
# Second layer
88+
lay1.y_title('Exp(2x)')
89+
lay1.y_title_size(20)
90+
# Second data plot
91+
dp1.symb_type(2) #circle
92+
dp1.edge_color(255,0,0) #RGB
93+
dp1.face_color(255,255,255) #RGB
94+
```
95+
Figure plotted.
6296

63-
#fill reflines
64-
lay0.refline_fill_ver(0,1,255,255,0)
97+
![Origin Plot Example]()
6598

66-
#delete objects
67-
gp.destroy()
99+
Reference lines can also be added to the figure
100+
```python
101+
# List of x axis values as the reference line positions
102+
lay0.reflines_ver([0,1,2])
103+
# Can fill the space between two reflines with colors
104+
lay0.refline_fill_ver(0,1,128,172,242)
68105
```
106+
![Origin Plot With Ref Lines]()
107+
69108
Dependencies:
70109
-----
71110

imgs/plot1.JPG

145 KB
Loading

imgs/plot1_ver.JPG

163 KB
Loading

imgs/plot1_ver_fill.JPG

160 KB
Loading

0 commit comments

Comments
 (0)