You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+78-39Lines changed: 78 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,11 @@
1
1
# 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.
3
3
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.
5
5
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:
7
9
-----
8
10
Clone the repo:
9
11
@@ -14,7 +16,7 @@ Clone the repo:
14
16
In the cloned directory:
15
17
16
18
``
17
-
python setyp.py sdist
19
+
python setup.py sdist
18
20
``
19
21
20
22
``
@@ -23,49 +25,86 @@ Clone the repo:
23
25
24
26
Usage:
25
27
-----
28
+
Import Library
26
29
```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
33
31
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')
35
56
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
45
68
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)')
52
80
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.
62
96
63
-
#fill reflines
64
-
lay0.refline_fill_ver(0,1,255,255,0)
97
+
![Origin Plot Example]()
65
98
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
0 commit comments