ScatterChart(x=None, y=None, color=None, color_by=None, size_by=None, marker=MarkerShape.CIRCLE, opacity=1.0, point_size=None, scale=None)
Source¶
Bases: Chart
Chart drawing each row as a point, used by Plot.scatter.
A row with a missing value in one of the columns used is not drawn. In a dense cloud, a low opacity shows where
the points gather, and a small point_size separates them. The last group drawn stays on top of the others.
Changed in version 0.2.0
The groups of color_by follow the natural order of their values, or the order of the categories,
instead of the order of the rows.
Version history (1)
Added in version 0.1.0
Parameters:
-
x(str | None, default:None)For a Table, the column of the horizontal positions: numbers, dates, datetimes, times of day, texts or booleans, the row numbers when omitted. An Array takes none, its rows being numbered. Times of day are placed on an axis of one day labeled
HH:MM. -
y(str | None, default:None)For a Table, the column of the vertical positions, holding numbers or times of day, the latter on an axis labeled
HH:MM. A Table needs it. An Array takes none: when omitted, each of its columns is a series of points. -
color(Color | CustomColor | None, default:None)The color of every point, the first color of the default cycle when omitted. With an Array of several columns, the series take the colors of the default cycle and
coloris refused. -
color_by(str | None, default:None)For a Table, the column coloring each point: numbers give a color scale shown next to the axes, texts, booleans and times of day give one color per value, named in the legend, times being written
HH:MM. The legend and the colors follow the order of the categories of a column of categories, and the natural order of any other values: numbers inside texts as numbers,Cluster 2beforeCluster 10, without regard to case. Every point takes the same color when omitted. -
size_by(str | None, default:None)For a Table, the column of numbers sizing each point, from the smallest to the largest value. Every point has the same size when omitted.
-
marker(MarkerShape, default:MarkerShape.CIRCLE)The shape of the points,
MarkerShape.CIRCLEby default. -
opacity(float, default:1.0)How opaque the points are, above 0 and up to 1,
1.0by default. The legend and the color scale stay opaque. -
point_size(float | None, default:None)The diameter of every point, in typographic points, 6 when omitted.
-
scale(ColorScale | None, default:None)
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
InvalidColumnNameErrorWhen
x,y,color_byorsize_byis an empty text. -
ConflictingSettingsErrorWhen
colorandcolor_byare both given, orpoint_sizeandsize_by. -
RefusedSettingErrorWhen
markerisMarkerShape.NONE, which would draw nothing, orscaleis given withoutcolor_by. -
InvalidOpacityErrorWhen
opacityis 0 or lower, greater than 1, or not a number. -
InvalidPointSizeErrorWhen
point_sizeis 0 or lower, infinite, or not a number.
Examples:
import numdaplot as ndp
surfaces = ndp.Array.from_list([30.0, 45.0, 60.0, 80.0, 52.0])
prices = ndp.Array.from_list([150.0, 210.0, 260.0, 330.0, 190.0])
cities = ndp.Array.from_list(["Paris", "Paris", "Lyon", "Lyon", "Pau"])
flats = ndp.Table.from_arrays({"surface": surfaces, "price": prices, "city": cities})
chart = ndp.ScatterChart(x="surface", y="price", color_by="city", size_by="surface")
plot = ndp.Plot.scatter(flats, chart)
plot.show()