-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logarithmic and power projections (#742)
- Loading branch information
1 parent
9c357f3
commit adf5e4d
Showing
3 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
examples/projections/nongeo/cartesian.py → ...es/projections/nongeo/cartesian_linear.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
Cartesian logarithmic | ||
===================== | ||
``xwidth[l]/[height[l]]``: Give the ``width`` of the figure and the optional argument \ | ||
``height``. The axis or axes with a logarithmic transformation requires ``l`` after | ||
its size argument. | ||
""" | ||
import numpy as np | ||
import pygmt | ||
|
||
# Create a list of x values 0-100 | ||
xline = np.arange(0, 101) | ||
# Create a list of y-values that are the square root of the x-values | ||
yline = xline ** 0.5 | ||
# Create a list of x values for every 10 in 0-100 | ||
xpoints = np.arange(0, 101, 10) | ||
# Create a list of y-values that are the square root of the x-values | ||
ypoints = xpoints ** 0.5 | ||
|
||
fig = pygmt.Figure() | ||
fig.plot( | ||
region=[1, 100, 0, 10], | ||
# Set a logarithmic transformation on the x-axis | ||
projection="X15cl/10c", | ||
# Set the figures frame, color, and gridlines | ||
frame=["WSne+gbisque", "x2g3", "ya2f1g2"], | ||
x=xline, | ||
y=yline, | ||
# Set the line thickness to *1p*, the color to *blue*, and the style to *dash* | ||
pen="1p,blue,-", | ||
) | ||
# Plot square root values as points on the line | ||
# Style of points is 0.3 cm square, color is *red* with a *black* outline | ||
# Points are not clipped if they go off the figure | ||
fig.plot(x=xpoints, y=ypoints, style="s0.3c", color="red", no_clip=True, pen="black") | ||
fig.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Cartesian power | ||
=============== | ||
**X**\ *width*\ [**p**\ *pvalue*]/[*height*\ [**p**\ *pvalue*]]: Give the | ||
*width* of the figure and the optional argument *height*. The axis or axes with a | ||
logarithmic transformation requires **p** and the power transformation for that axis. | ||
""" | ||
import numpy as np | ||
import pygmt | ||
|
||
# Create a list of y values 0-10 | ||
yvalues = np.arange(0, 11) | ||
# Create a list of x-values that are the square of the y-values | ||
xvalues = yvalues ** 2 | ||
|
||
fig = pygmt.Figure() | ||
fig.plot( | ||
region=[0, 100, 0, 10], | ||
# Set the power transformation of the x-axis, with a power of 0.5 | ||
projection="X15cp0.5/10c", | ||
# Set the figures frame, color, and gridlines | ||
frame=["WSne+givory", "xa1p", "ya2f1"], | ||
# Set the line thickness to *thick* | ||
# Use the default color *black* and the default style *solid* | ||
pen="thick", | ||
x=xvalues, | ||
y=yvalues, | ||
) | ||
# Plot x,y values as points on the line | ||
# Style of points is 0.2 cm circles, color is *green* with a *black* outline | ||
# Points are not clipped if they go off the figure | ||
fig.plot(x=xvalues, y=yvalues, style="c0.2c", color="green", no_clip=True, pen="black") | ||
fig.show() |