Skip to content

Commit 6dfd9df

Browse files
committed
Merge pull request bqplot#22 from bloomberg/readme_screenshots
Adding screenshots and update Readme.md examples
2 parents 68e80c1 + e5c9f12 commit 6dfd9df

File tree

3 files changed

+48
-78
lines changed

3 files changed

+48
-78
lines changed

README.md

+48-78
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Goals
1313
- provide a sensible API for adding user interactions (panning, zooming, selection, etc)
1414
- pip installable
1515

16-
Two main APIs are provided
16+
Two APIs are provided
1717

1818
- Users can build a custom visualization using our object model, that is inspired by
1919
the constructs of the Grammar of Graphics (figure, marks, axes, scales), and enrich their
@@ -67,92 +67,62 @@ This package depends on the following packages:
6767
6868
6969
### Loading `bqplot`
70-
# In an IPython shell
71-
$ ipython
72-
In [1]: import bqplot
70+
71+
```python
72+
# In a Jupyter notebook
73+
import bqplot
74+
```
7375

7476
That's it! You're ready to go!
7577

7678
Examples
7779
--------
7880

79-
1. Using the `bqplot` internal object model
80-
81-
82-
```python
83-
import numpy as np
84-
from IPython.display import display
85-
from bqplot import *
86-
87-
n = 10
88-
x_data = np.arange(n)
89-
y_data = np.cumsum(np.random.randn(n)) * 100.0
90-
y_data_2 = np.cumsum(np.random.randn(n)) * 100.0
91-
y_data_3 = np.cumsum(np.random.randn(n)) * 100.0
92-
93-
sc_ord = OrdinalScale()
94-
sc_y = LinearScale()
95-
sc_y_2 = LinearScale()
96-
97-
ord_ax = Axis(scale=sc_ord,
98-
label='Test X',
99-
tick_format='0.0f',
100-
grid_lines='none')
101-
102-
y_ax = Axis(scale=sc_y,
103-
label='Test Y',
104-
tick_format='0.2f',
105-
grid_lines='solid',
106-
orientation='vertical')
107-
108-
y_ax_2 = Axis(label='Test Y 2',
109-
scale=sc_y_2,
110-
orientation='vertical',
111-
side='right',
112-
tick_format='0.0f',
113-
grid_lines='dashed')
114-
115-
line_chart = Lines(x=x_data,
116-
y=[y_data, y_data_2, y_data_3],
117-
scales={
118-
'x': sc_ord,
119-
'y': sc_y,
120-
},
121-
stroke_width=3,
122-
labels=['Line1', 'Line2', 'Line3'],
123-
display_legend=True)
124-
125-
bar_chart = Bars(x=x_data,
126-
y=[y_data, y_data_2, y_data_3],
127-
scales={
128-
'x': sc_ord,
129-
'y': sc_y_2,
130-
},
131-
opacity=0.5,
132-
labels=['Bar1', 'Bar2', 'Bar3'],
133-
display_legend=True)
134-
135-
fig = Figure(axes=[ord_ax, y_ax, y_ax_2],
136-
marks=[bar_chart, line_chart],
137-
legend_location='top-left')
138-
139-
display(fig)
140-
```
81+
### Using the `pyplot` API
14182

142-
2. Using the `pyplot` API
83+
```python
84+
from bqplot import pyplot as plt
85+
import numpy as np
14386

144-
```python
145-
from bqplot import pyplot as plt
146-
import numpy as np
87+
plt.figure(1)
88+
np.random.seed(0)
89+
n = 200
90+
x = np.linspace(0.0, 10.0, n)
91+
y = np.cumsum(np.random.randn(n))
92+
plt.plot(x,y, axes_options={'y': {'grid_lines': 'dashed'}})
93+
plt.show()
94+
```
14795

148-
plt.figure(1)
149-
np.random.seed(0)
150-
n = 200
151-
x = np.linspace(0.0, 10.0, n)
152-
y = np.cumsum(np.random.randn(n))
153-
plt.plot(x,y, axes_options={'y': {'grid_lines': 'dashed'}})
154-
plt.show()
155-
```
96+
![Pyplot Screenshot](/pyplot-screenshot.png)
97+
98+
### Using the `bqplot` internal object model
99+
100+
101+
```python
102+
import numpy as np
103+
from IPython.display import display
104+
from bqplot import *
105+
106+
size = 20
107+
np.random.seed(0)
108+
109+
x_data = np.arange(size)
110+
111+
x_ord = OrdinalScale()
112+
y_sc = LinearScale()
113+
114+
bar = Bars(x=x_data, y=np.random.randn(2, size), scales={'x': x_ord, 'y': y_sc}, type='stacked')
115+
line = Lines(x=x_data, y=np.random.randn(size), scales={'x': x_ord, 'y': y_sc},
116+
stroke_width=3, colors=['red'], display_legend=True, labels=['Line chart'])
117+
118+
ax_x = Axis(scale=x_ord)
119+
ax_y = Axis(scale=y_sc, orientation='vertical', tick_format='0.2f', grid_lines='solid')
120+
121+
fig = Figure(marks=[bar, line], axes=[ax_x, ax_y])
122+
display(fig)
123+
```
124+
125+
![Bqplot Screenshot](/bqplot-screenshot.png)
156126

157127
License
158128
-------

bqplot-screenshot.png

41.1 KB
Loading

pyplot-screenshot.png

50.7 KB
Loading

0 commit comments

Comments
 (0)