diff --git a/examples/gallery/3d_plots/scatter3d.py b/examples/gallery/3d_plots/scatter3d.py index 0c70581fe32..d094d25f43b 100644 --- a/examples/gallery/3d_plots/scatter3d.py +++ b/examples/gallery/3d_plots/scatter3d.py @@ -17,7 +17,7 @@ import pandas as pd import pygmt -# Load sample iris data, and convert 'species' column to categorical dtype +# Load sample iris data and convert 'species' column to categorical dtype df = pd.read_csv("https://github.com/mwaskom/seaborn-data/raw/master/iris.csv") df.species = df.species.astype(dtype="category") @@ -36,9 +36,12 @@ # Define a colormap to be used for three categories, define the range of the # new discrete CPT using series=(lowest_value, highest_value, interval), -# use color_model="+c" to write the discrete color palette "cubhelix" in -# categorical format -pygmt.makecpt(cmap="cubhelix", color_model="+c", series=(0, 3, 1)) +# use color_model="+cSetosa,Versicolor,Virginica" to write the discrete color palette +# "cubhelix" in categorical format and add the species names as annotations for the +# colorbar +pygmt.makecpt( + cmap="cubhelix", color_model="+cSetosa,Versicolor,Virginica", series=(0, 2, 1) +) fig.plot3d( # Use petal width, sepal length and petal length as x, y and z data input, @@ -58,14 +61,18 @@ region=region, # Set frame parameters frame=[ - "WsNeZ3", # z axis label positioned on 3rd corner - 'xafg+l"Petal Width"', - 'yafg+l"Sepal Length"', - 'zafg+l"Petal Length"', + 'WsNeZ3+t"Iris flower data set"', # z axis label positioned on 3rd corner, add title + 'xafg+l"Petal Width (cm)"', + 'yafg+l"Sepal Length (cm)"', + 'zafg+l"Petal Length (cm)"', ], # Set perspective to azimuth NorthWest (315°), at elevation 25° perspective=[315, 25], # Vertical exaggeration factor zscale=1.5, ) + +# Add colorbar legend +fig.colorbar(xshift=3.1) + fig.show() diff --git a/examples/gallery/lines/line_custom_cpt.py b/examples/gallery/lines/line_custom_cpt.py index bb42c9e54e3..756aef38b7a 100644 --- a/examples/gallery/lines/line_custom_cpt.py +++ b/examples/gallery/lines/line_custom_cpt.py @@ -21,13 +21,16 @@ fig = pygmt.Figure() fig.basemap(frame=["WSne", "af"], region=[20, 30, -10, 10]) -# Create a custom CPT with the batlow CPT and 10 discrete z-values (colors) -pygmt.makecpt(cmap="batlow", series=[0, 10, 1]) +# Create a custom CPT with the batlow CPT and 10 discrete z-values (colors), +# use color_model="+c0-9" to write the color palette in categorical format and +# add labels (0) to (9) for the colorbar legend +pygmt.makecpt(cmap="batlow", series=[0, 9, 1], color_model="+c0-9") # Plot 10 lines and set a different z-value for each line for zvalue in range(0, 10): y = zvalue * np.sin(x) fig.plot(x=x, y=y, cmap=True, zvalue=zvalue, pen="thick,+z,-") + # Color bar to show the custom CPT and the associated z-values fig.colorbar() fig.show() diff --git a/examples/gallery/symbols/points_categorical.py b/examples/gallery/symbols/points_categorical.py index 3abf829e7ff..de5ad85a36c 100644 --- a/examples/gallery/symbols/points_categorical.py +++ b/examples/gallery/symbols/points_categorical.py @@ -44,9 +44,10 @@ # Define a colormap to be used for three categories, define the range of the # new discrete CPT using series=(lowest_value, highest_value, interval), -# use color_model="+c" to write the discrete color palette "inferno" in -# categorical format -pygmt.makecpt(cmap="inferno", series=(0, 3, 1), color_model="+c") +# use color_model="+cAdelie,Chinstrap,Gentoo" to write the discrete color palette +# "inferno" in categorical format and add the species names as annotations for the +# colorbar +pygmt.makecpt(cmap="inferno", series=(0, 2, 1), color_model="+cAdelie,Chinstrap,Gentoo") fig.plot( # Use bill length and bill depth as x and y data input, respectively @@ -66,7 +67,7 @@ transparency=40, ) -# A colorbar displaying the different penguin species types will be added -# once GMT 6.2.0 is released. +# Add colorbar legend +fig.colorbar() fig.show()