Skip to content

Commit 60ade1c

Browse files
committed
updates based on code review
1 parent 1790cbd commit 60ade1c

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

examples/gallery/3d_plots/scatter3d.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,8 @@
1717
import pandas as pd
1818
import pygmt
1919

20-
# Load sample iris data
20+
# Load sample iris data and convert 'species' column to categorical dtype
2121
df = pd.read_csv("https://github.com/mwaskom/seaborn-data/raw/master/iris.csv")
22-
23-
# Extract species names for colorbar legend
24-
species = ",".join(df.species.unique())
25-
26-
# Convert 'species' column to categorical dtype
2722
df.species = df.species.astype(dtype="category")
2823

2924
# Use pygmt.info to get region bounds (xmin, xmax, ymin, ymax, zmin, zmax)
@@ -41,9 +36,11 @@
4136

4237
# Define a colormap to be used for three categories, define the range of the
4338
# new discrete CPT using series=(lowest_value, highest_value, interval),
44-
# use color_model="+c" + species to write the discrete color palette "cubhelix" in
45-
# categorical format and add the species names extracted above as annotations
46-
pygmt.makecpt(cmap="cubhelix", color_model="+c" + species, series=(0, 2, 1))
39+
# use color_model="+csetosa,versicolor,virginica" to write the discrete color palette
40+
# "cubhelix" in categorical format and add the species names as annotations
41+
pygmt.makecpt(
42+
cmap="cubhelix", color_model="+csetosa,versicolor,virginica", series=(0, 2, 1)
43+
)
4744

4845
fig.plot3d(
4946
# Use petal width, sepal length and petal length as x, y and z data input,
@@ -75,6 +72,6 @@
7572
)
7673

7774
# Add colorbar legend
78-
fig.colorbar()
75+
fig.colorbar(xshift=3.1)
7976

8077
fig.show()

0 commit comments

Comments
 (0)