How to reduce width of the errorbar and the errorbar cap

Dear experts,
I am able to plot the errorbar on the map by using the below code. But i want to change the width of the errorbar and errorbar cap. How to do it can you please suggest.

import pandas as pd
import pygmt

df = pd.DataFrame(
data={
“x”: [181.89470, 181.89470, 195.63454, 195.63454, 195.63454],
“y”: [-4.0, -4.0, -4.0, -4.0, -4.0],
“x-error”: [0.5, 0.0, 0.0, 0.5, 0.0],
“y-error”: [1.0, 1.0, 1.5, 1.5, 1.5],
}
)

fig = pygmt.Figure()
fig.plot(data=df.to_numpy(), region=[180., 198., -6., -2.], error_bar=True, frame=True)
fig.show()

Is -E modifier implemented in pygmt ?

1 Like

Hello @seis,

in PyGMT E is aliased with error_bar. You can append (see plot — GMT 6.4.0 documentation (generic-mapping-tools.org)):

  • +a for asymmetric error bars
  • +w to adjust the cap size
  • +p to adjust the width and color of the bar

Please find below an example as orientation (PyGMT v0.7.0 and GMT 6.4.0):

import pandas as pd
import pygmt

df = pd.DataFrame(
    data={
    "x": [5],
    "y": [5],
    "x-error-low": [1],
    "x-error-upp": [2],
    "y-error-low": [2.5],
    "y-error-upp": [3],
    }
)

fig = pygmt.Figure()

fig.plot(data=df.to_numpy(),
         region=[0, 10, 0, 10],
         projection="X10c",
         # +a asymmetric errorbars
         # +w size of cap
         # +p width, color of bar
         error_bar="+a+w10p+p2p,red",
         style="c0.25c",  # circle
         pen="1p,black",  # outline width and color
         color="green",  # fill color
         frame="a1fg1",
)

fig.show()

Output figure:

1 Like

Thank you very much for your answer.