Skip to content

Commit 97c58b4

Browse files
committed
update script and readme
- improved stereoplot function - update readme with new syntax
1 parent bafd448 commit 97c58b4

File tree

2 files changed

+13
-32
lines changed

2 files changed

+13
-32
lines changed

JASPE.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,23 @@
4040
import pandas as pd
4141
import os
4242

43-
# Example
44-
# fig, (ax1, ax2) = stereoplot(number=2, nrows=1, ncols=2)
45-
# fig, (ax1, ax2, ax3) = stereoplot(number=3, nrows=3, ncols=1)
43+
# Examples
44+
# fig, ax = stereoplot()
45+
# fig, (ax1, ax2) = stereoplot(nrows=1, ncols=2)
46+
# fig, (ax1, ax2, ax3, ax4) = stereoplot(nrows=2, ncols=2)
4647

4748

48-
def stereoplot(number=1, nrows=1, ncols=1):
49+
def stereoplot(nrows=1, ncols=1):
4950
"""Automatically generate a defined number of stereoplots (between 1 and 5)
5051
using the matplotlib library
5152
5253
Parameters
5354
----------
54-
form: integer between 1 and 5
55-
the number of stereos, up to 5
56-
5755
nrows: integer
5856
the number of rows of the subplot grid
5957
6058
ncols: integer
61-
the number of columns of the subplot grid
62-
63-
Assumptions
64-
-----------
65-
- nrows * ncols must be equal to the number of stereos
59+
the number of columns of the subplot grid
6660
6761
Call functions
6862
--------------
@@ -72,12 +66,9 @@ def stereoplot(number=1, nrows=1, ncols=1):
7266
------
7367
TODO
7468
"""
69+
num_plots = nrows * ncols
7570

76-
if nrows * ncols != number:
77-
print('nrows times ncols must be equal to the number of stereos!')
78-
return None
79-
80-
if number == 1:
71+
if num_plots == 1:
8172
fig, ax = plt.subplots()
8273
set_stereo(ax)
8374
fig.tight_layout()
@@ -89,7 +80,7 @@ def stereoplot(number=1, nrows=1, ncols=1):
8980
fig, ax = plt.subplots(nrows=nrows, ncols=ncols, sharey=True)
9081
elif ncols == 1:
9182
fig, ax = plt.subplots(nrows=nrows, ncols=ncols, sharex=True)
92-
else: # not yet implemented
83+
else:
9384
fig, ax = plt.subplots(nrows=nrows, ncols=ncols)
9485

9586
for item in fig.axes:

README.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ So far, the script only performs very basic tasks. One function tweaks the defau
99
## Quick examples
1010

1111
```python
12-
# Create a simple figure
13-
fig, ax = plt.subplots()
14-
15-
# set the plot
16-
set_stereo(ax) # set the stereo
17-
fig.tight_layout() # assure a tight layout
12+
# Create a simple stereoplot
13+
fig, ax = stereoplot()
1814

1915
# Plot some data using the function plot_data
2016
plot_data(180, 45, ax) # by default this is an equal-area projection
@@ -23,21 +19,15 @@ plot_data(180, 45, ax, form='angle') # plot in equal-angle projection
2319
![](https://raw.githubusercontent.com/marcoalopez/JASPE/master/figs/one_plot.png)
2420

2521
```python
26-
# Create a figure with two stereos using matplotlib [oo] syntax
27-
fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, sharey=True)
28-
29-
# set the plots
30-
set_stereo(ax1)
31-
set_stereo(ax2)
32-
fig.tight_layout()
22+
# Create a figure with two stereos (1 row * 2 columns)
23+
fig, (ax1, ax2) = stereoplot(nrows=1, ncols=2)
3324

3425
# plot linear data in the first stereo (ax1)
3526
azimuths = [0, 45, 90, 135, 180, 225, 270, 315, 360]
3627
dips = [0, 10, 20, 30, 40, 50, 70, 80, 90]
3728
plot_data(azimuths, dips, ax1)
3829

3930
# plot linear data from a txt file in the second stereo (ax2)
40-
4131
## import tabular-like data from text files. The function will ask you for
4232
## the location of the file through a file selection dialog
4333
dataset = import_data()

0 commit comments

Comments
 (0)