Closed sungho91 closed 5 months ago
👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.
Hello @sungho91,
As we do not have your input data, we cannot run your script.
However, I think the vectors within the orange-dashed box are drawn without heads because the vector length is too short relatively to the size of the heads. Please find below a general code example showing this:
import numpy as np
import pygmt
x = np.linspace(0.2, 0.2, 6) # x vector coordinates
y = np.linspace(-2, 2, 6) # y vector coordinates
direction = np.zeros(x.shape) # direction of vectors
length = np.linspace(0.1, 1.4, 6) # length of vectors
fig = pygmt.Figure()
fig.basemap(region=[0, 10, -2.5, 2.5], projection="X5c/3c", frame=0)
# Plot Cartesian vectors with different lengths and diffent head sizes
fig.plot(x=x, y=y, style="v0.4c+e", direction=[direction, length])
fig.plot(x=x+3.3, y=y, style="v0.2c+e", direction=[direction, length])
fig.plot(x=x+6.6, y=y, style="v0.1c+e", direction=[direction, length])
fig.show()
Hi @yvonnefroehlich
Thank you for your comment. I've attached my files to this. So, if the length of velocity is too small, there is no way to plot them with a head?
I think you need to use +n
in the style
parameter. See https://docs.generic-mapping-tools.org/dev/plot.html#vector-attributes
I think you need to use
+n
in thestyle
parameter. See https://docs.generic-mapping-tools.org/dev/plot.html#vector-attributes
I just modified my code example to compare the results without (black) and with (red) using +n
:
# Modified from https://www.pygmt.org/dev/gallery/lines/vector_styles.html#sphx-glr-gallery-lines-vector-styles-py
# Last access 2024/06/03
import numpy as np
import pygmt
x = np.linspace(0.4, 0.4, 4) # x vector coordinates
y = np.linspace(-1, 1, 4) # y vector coordinates
direction = np.zeros(x.shape) # direction of vectors
length = np.linspace(0.1, 0.5, 4) # length of vectors
fig = pygmt.Figure()
fig.basemap(region=[0, 3, -1.5, 1.5], projection="X3c/2c", frame=0)
for keep_head in ["", "+n"]:
match keep_head:
case "": pen = "0.7p,black"
case "+n": pen = "0.2p,red"
# Plot Cartesian vectors with different lengths and diffent head sizes
fig.plot(x=x, y=y, style=f"v0.4c+e{keep_head}", pen=pen, direction=[direction, length])
fig.plot(x=x+1, y=y, style=f"v0.2c+e{keep_head}", pen=pen, direction=[direction, length])
fig.plot(x=x+2, y=y, style=f"v0.1c+e{keep_head}", pen=pen, direction=[direction, length])
fig.show(dpi=720)
This is really helpful. It just occurred to me. I just adjusted very small size lengths to a certain magnitude. FYI, it also works.
Description of the problem
Hi
All vectors should have a head but some of them don't have (orange-dotted box in att.). How can I fix them?
Best,
Sungho
Minimal Complete Verifiable Example
Full error message
No response
System information