Skip to content

Commit

Permalink
Merge branch 'master' into improve-docs/plot
Browse files Browse the repository at this point in the history
  • Loading branch information
weiji14 committed Oct 24, 2020
2 parents 23d09dc + 828ac3e commit 6ef0eee
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
39 changes: 26 additions & 13 deletions examples/gallery/line/linestyles.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,36 @@
import numpy as np
import pygmt

# Generate a sample line for plotting
x = np.linspace(0, 10, 500)
y = np.sin(x)
# Generate a two-point line for plotting
x = np.array([0, 7])
y = np.array([9, 9])

fig = pygmt.Figure()
fig.basemap(region=[0, 10, -3, 3], projection="X15c/8c", frame=["xaf", "yaf", "WSrt"])
fig.basemap(region=[0, 10, 0, 10], projection="X15c/8c", frame='+t"Line Styles"')

# Plot the line using the default line style
fig.plot(x=x, y=y)

# Plot the lines using different line styles
fig.plot(x=x, y=y + 1.5, pen="1p,red,-")
fig.plot(x=x, y=y + 1.0, pen="2p,blue,.")
fig.plot(x=x, y=y + 0.5, pen="1p,red,-.")

fig.plot(x=x, y=y - 0.5, pen="2p,blue,..-")
fig.plot(x=x, y=y - 1.0, pen="3p,tomato,--.")
fig.plot(x=x, y=y - 1.5, pen="3p,tomato,4_2:2p")
fig.text(x=x[-1], y=y[-1], text="solid (default)", justify="ML", offset="0.2c/0c")

# Plot the line using different line styles
for linestyle in [
"1p,red,-", # dashed line
"1p,blue,.", # dotted line
"1p,lightblue,-.", # dash-dotted line
"2p,blue,..-", # dot-dot-dashed line
"2p,tomato,--.", # dash-dash-dotted line
"2p,tomato,4_2:2p", # A pattern of 4-point-long line segment and 2-point-gap between segment
]:
y -= 1 # Move the current line down
fig.plot(x=x, y=y, pen=linestyle)
fig.text(x=x[-1], y=y[-1], text=linestyle, justify="ML", offset="0.2c/0c")

# Plot the line like a railway track (black/white).
# The trick here is plotting the same line twice but with different line styles
y -= 1 # move the current line down
fig.plot(x=x, y=y, pen="5p,black")
fig.plot(x=x, y=y, pen="4p,white,20p_20p")
fig.text(x=x[-1], y=y[-1], text="5p,black", justify="ML", offset="0.2c/0.2c")
fig.text(x=x[-1], y=y[-1], text="4p,white,20p_20p", justify="ML", offset="0.2c/-0.2c")

fig.show()
10 changes: 7 additions & 3 deletions pygmt/tests/test_grdimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ def test_grdimage_file():
return fig


@pytest.mark.skip(
reason="Upstream bug in GMT 6.1.1",
condition=gmt_version <= Version("6.1.1") and sys.platform == "darwin",
@pytest.mark.skipif(
gmt_version <= Version("6.1.1") and sys.platform == "darwin",
reason="Upstream bug in GMT 6.1.1 that causes segfault on macOS",
)
@pytest.mark.xfail(
condition=gmt_version <= Version("6.1.1") and sys.platform != "darwin",
reason="Upstream bug in GMT 6.1.1 that causes this test to fail on Linux/Windows",
)
@check_figures_equal()
@pytest.mark.parametrize(
Expand Down

0 comments on commit 6ef0eee

Please sign in to comment.