-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plot(x, y, G=value, C=cmap) gives strange behavior for individual points #417
Comments
👋 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. |
Right, bear with me for a little bit while I get my head around this. I think this is similar to the problem we had in #376. To colour your points in the for-loop, the Edit: To colour the polygon, you can set the # Single Calls Only : doesn't do the right thing
fig = pygmt.Figure()
title="+t\"Single Calls to CMAP - Odd.\"";
fig.coast(region=[-124, -120, 35, 39],projection="M7i",shorelines="1.0p,black",B=[title,"1.0"]);
fig.colorbar(D="jBr+w3.5i/0.2i+o5.5c/1.5c+h",C="mycpt.cpt",I="0.8",G="-1.0/1.0",B=["x"+str(0.2),"y+L\"KPa\""]);
for i in range(len(xdata)): # just looping through the data
fig.plot(x=xdata[i], y=ydata[i], G=[zdata[i]], style="c1.8c", pen="thick,black", C="mycpt.cpt"); # plotting a point with associated cmap data
xdata_long = [xdata[i]+0.2, xdata[i]+0.3, xdata[i]+0.3, xdata[i]+0.2, xdata[i]+0.2]; # building a polygon
ydata_long = [ydata[i], ydata[i], ydata[i]+0.1, ydata[i]+0.1, ydata[i]]; # building a polygon
fig.plot(x=xdata_long, y=ydata_long, pen="thick,black", C="mycpt.cpt", Z="f" + str(zdata[i])); # plotting the polygon with associated cmap data
fig.savefig("Somewhat_Working.png"); produces:
|
Thank you so much for your quick reply- this is exactly it! 🎉🎉🎉 |
Yes it does get a bit confusing, but glad it helped. The I'll leave this issue open for now until we clear up the |
Documentation for |
Description of the problem
In plot(), using G=value and C=cmap to interpret a color from a CMAP for a single value doesn't work in the same way that a list/array of values does. Interpreting a single value from a color map would be useful for plotting a bunch polygons with different colors (ex: for coulomb stress changes on fault segments).
In the single-element case, plot() requires G=str, which is also counter-intuitive.
Either way, the result makes it difficult to plot custom-colored polygons with a colormap
(usually I would just extract a color for each polygon and plot each one separately, calling plot() in a loop). Is there another way to plot polygons with cmap colors?
In the example code, I'm plotting some dummy data, once as an array of points, and once in a for-loop with points and polygons in individual plot() calls. The cmap behavior is quite different.
Full code that generated the error
System information
Mac OSX Mojave, miniconda3 package manager, python3.6. I installed pygmt in a brand new python environment today.
The text was updated successfully, but these errors were encountered: