-
Notifications
You must be signed in to change notification settings - Fork 213
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
Problem coloring symbols in pygmt v0.11 with plot and plot3d commands #3219
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. |
Perhaps you need to set the fill like |
I think there are two options to accomplish color-coding (and size-coding) (see the code example below):
Another aspect is that you set the Input data: MT-dev_inv-results.txt import pandas as pd
import pygmt
file = "MT-dev_inv-results.txt"
cols2_use = [
"Date", "Hour_UTC", "Latitude", "Longitude", "SGC_depth",
"Lat-cent", "Lon-cent", "Mt_depth", "Variance",
"VarRed", "Pdc", "Pclvd", "Piso", "Mw_x", "Mw_y",
]
data_dev = pd.read_csv(file, usecols=cols2_use, delimiter=" ")
region = pygmt.info(
data=data_dev[["Longitude", "Latitude", "SGC_depth"]],
per_column=True,
spacing=(0.2, 0.2, 50),
)
fig = pygmt.Figure()
pygmt.makecpt(cmap="viridis", series=(100, 200, 1), continuous=None)
fig.plot3d(
x=data_dev["Longitude"],
y=data_dev["Latitude"],
z=data_dev["SGC_depth"],
fill=data_dev["SGC_depth"],
# OR
# data=data_dev[["Longitude", "Latitude", "SGC_depth", "SGC_depth"]],
cmap=True,
style="u0.15c",
region=region,
# size=data_dev["Mw_x"]*1.2, # Ignored when a fixed size via style is set
perspective=[240, 30],
zscale=-0.05,
)
fig.plot3d(
# x=data_dev["Lon-cent"],
# y=data_dev["Lat-cent"],
# z=data_dev["Mt_depth"],
# fill=data_dev["Mt_depth"],
# OR
data=data_dev[["Lon-cent", "Lat-cent", "Mt_depth", "Mt_depth"]],
cmap=True,
style="u0.3c",
region=region,
perspective=[240, 30],
zscale=-0.05,
frame=[
"WSneZ",
"xa0.2f0.1g0.1+lLongitude [°]",
"ya0.2f0.1g0.1+lLatitude [°]",
"za50f20g20+lDepth [km]",
]
)
fig.colorbar(frame=["a20f10", "y+lkm"], position="JRM")
fig.show() |
Thanks for your comments. Including the line proposed by @seisman, solve the problem. I see that the input in fill parameter, need to put values of the variable used to make the correspond colorbar. I also thanks the explannation given to generate size-coding by @yvonnefroehlich |
Description of the problem
Greetings,
I'm having troubles filling symbols with the colors based on a different variable using PyGMT v0.11 and GMT 6.3 plot3d commands in Ubuntu 18.04 OS. This is the same issue reported in this post https://forum.generic-mapping-tools.org/t/coloring-symbols-with-cpt-pygmt/4034. I have seen other comments, but none of them seem to work for my case.
I test the example 3d scatter plot found in the pygmt webpage and works normally. The problem appeared when I try to plot in 3d view some earthquakes and colored according to different depth values. The data is saved into a pandas dataframe,
data_dev
that have this structure:Below is the code than I'm using
The figure that it creates is the following and in the console doesn't appear any error or warning
![imagen](https://private-user-images.githubusercontent.com/106351986/326998698-a4a0927c-2623-4524-9027-01a6eda50916.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA4MjgzNDcsIm5iZiI6MTcyMDgyODA0NywicGF0aCI6Ii8xMDYzNTE5ODYvMzI2OTk4Njk4LWE0YTA5MjdjLTI2MjMtNDUyNC05MDI3LTAxYTZlZGE1MDkxNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcxMlQyMzQ3MjdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wOGViM2M5MzI5ZmFhZGNiN2M5N2Y4ZTk5NDU3MzE1YjRjMDdmODIyNjdhMTk1ZDI0ZWMwZWExZmZkYzg4Y2FkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.sPYgOJbht1SNPDWhDsmeon76ULHuc_7zabLEoQeUdjs)
The code runs, but all the cubes plot black instead of using the color palette that I assigned in makecpt. Is there any problem or error in the code wrote to plot the image.
Thank in advance for your help!!!
PD: I attach the output to the command
pygmt.show_versions()
below:PyGMT information:
version: v0.11.0
System information:
python: 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:38:13) [GCC 12.3.0]
executable: /home/william/anaconda3/envs/pygmt/bin/python
machine: Linux-5.4.0-150-generic-x86_64-with-glibc2.27
Dependency information:
numpy: 1.26.4
pandas: 2.2.2
xarray: 2024.3.0
netCDF4: 1.6.5
packaging: 24.0
contextily: None
geopandas: None
ipython: None
rioxarray: None
ghostscript: 10.03.0
GMT library information:
binary version: 6.5.0
cores: 12
grid layout: rows
image layout:
library path: /home/william/anaconda3/envs/pygmt/lib/libgmt.so
padding: 2
plugin dir: /home/william/anaconda3/envs/pygmt/lib/gmt/plugins
share dir: /home/william/anaconda3/envs/pygmt/share/gmt
version: 6.5.0
Minimal Complete Verifiable Example
No response
Full error message
No response
System information
The text was updated successfully, but these errors were encountered: