question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Figure.plot fails to plot lines correctly

See original GitHub issue

Description of the problem

Figure.plot() doesn’t plot simple lines correctly.

Full code that generated the error

import pygmt

fig = pygmt.Figure()
fig.basemap(J="X8c/8c", R="-10/10/0/10", B=True)
fig.plot(x=[0.0, 0.0], y=[0, 10], W="1p,gray,-")
fig.plot(x=[5.0, 5.0], y=[2, 8], W="1p,gray,-")
fig.plot(x=[3.0, 8.0], y=[0, 10], W="1p,gray,-")
fig.show(method="external")

Output plot plot-lines-fail

Only the first line is correct. The other two lines are wrong.

System information

  • Operating system: macOS
  • Python installation (Anaconda, system, ETS): Anaconda
  • Version of GMT: 6.0.0_15a9160
  • Version of Python: 3.7.0
  • Version of this package: latest
  • If using conda, paste the output of conda list below

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
seismancommented, May 14, 2020

The issue is caused by a GMT bug. See https://github.com/GenericMappingTools/gmt/issues/3330 for the detailed bug report. The bug was already fixed in PR https://github.com/GenericMappingTools/gmt/pull/3331 and the script above should work with the upcoming GMT 6.1.0 release.

I added an upstream label to this issue and keep the issue opening, as I don’t think we can/should do any hacking on the PyGMT side.

Since plot() is one of the most commonly used functions, I propose that, when GMT 6.1.0 is released, we should:

  • release PyGMT v0.1.1 or v0.2.0, and bump the minimum required GMT version to 6.1.0
  • add the example script to the test
1reaction
seismancommented, Feb 6, 2019

Using data instead of x and y also works.

import pygmt
import numpy as np

fig = pygmt.Figure()
fig.basemap(J="X8c/8c", R="-10/10/0/10", B=True)
fig.plot(data=np.column_stack([[0.0, 0.0], [0, 10]]), W="1p,gray,-")
fig.plot(data=np.column_stack([[5.0, 5.0], [2, 8]]), W="1p,gray,-")
fig.plot(data=np.column_stack([[3.0, 8.0], [0, 10]]), W="1p,gray,-")
fig.savefig("lines.png")
Read more comments on GitHub >

github_iconTop Results From Across the Web

Drawing objects do not plot and are missing from print preview ...
Issue: When plotting from AutoCAD, one or more drawing elements or lines do not show up in the output (PDF, hard copy) and...
Read more >
Lines/Tracks Not Plotting with Matplotlib - Stack Overflow
I am getting the markers to correctly plot with color but, the lines are not there. python · csv · matplotlib · matplotlib-basemap...
Read more >
Why won't my plot graph a line? - MATLAB Answers
But the real reason why your plot fails is every call that you make to plot, you are just plotting a SINGLE point....
Read more >
Resolved: Matplotlib figures not showing up or displaying
In this blog post I detailed how to resolve a pesky issue where matplotlib figures are not displayed to your screen. Symptoms of...
Read more >
A Complete Guide to Line Charts | Tutorial by Chartio
A line chart (aka line plot, line graph) uses points connected by line segments ... values if the line does not include distinct...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found