PlotStyle(title=None, x_label=None, y_label=None, right_label=None, x_tick_rotation=None, y_tick_rotation=None, legend=LegendPosition.BEST, grid_lines=GridLines.SHOWN, size=Size(), renaming=None)
Source¶
Look of a whole Plot: title, axis labels, rotation of the values, legend, grid lines and size.
The look of the series, such as their colors, belongs to the chart drawing them.
Added in version 0.1.0
Changed in version 0.2.0
The title is centered above the whole Plot, and goes on several lines when it is too wide. The axis of several
series is labeled Value by default, their names staying in the legend and the title.
Parameters:
-
title(str | None, default:None)The title, centered above the whole Plot and broken into lines when it is too wide: when omitted, the
ylabel by thexlabel such assales by month, and for a map of missing valuesMap of missing values. Several columns labeledValueare named in the title one after the other, the first 3 and the number of the others beyond 3, such asprice, cost by month. An empty text draws no title. -
x_label(str | None, default:None)The label of the axis of the
xvalues: when omitted, the name of thexcolumn, elseRow, orColumnfor a box or a heatmap without group. For a histogram, whose values are on this axis, the name of its single column, elseValue. An empty text draws no label. -
y_label(str | None, default:None)The label of the axis of the
yvalues: when omitted, the name of the singleycolumn, elseValuefor several columns, which the legend names, and for an Array. An empty text draws no label. -
right_label(str | None, default:None) -
x_tick_rotation(float | None, default:None)The angle of the labels of the
xvalues, in degrees from -90 to 90. When omitted, 45 degrees for texts, dates, datetimes and numbers without enough room, and no rotation for other numbers and for the texts on the left of horizontal bars. Labels without enough room at this angle are left out, one out of as many as needed from the first one, with aReadabilityWarningwhen they may be texts. -
y_tick_rotation(float | None, default:None)The angle of the labels of the
yvalues, in degrees from -90 to 90, no rotation when omitted. The values of the axis on the right keep no rotation. Labels without enough room are left out as forx_tick_rotation. -
legend(LegendPosition, default:LegendPosition.BEST)Where the legend is placed,
LegendPosition.BESTby default, past the axes for a map of missing values. It is only drawn for several series, so never on a pie or a heatmap. It names each series after its column, or after the namerenaminggives it. -
grid_lines(GridLines, default:GridLines.SHOWN) -
size(Size, default:Size())The width and the height, 6.4 by 4.8 inches by default. A Plot placed in a
Figuretakes the size of its cells instead. -
renaming(Renaming | None, default:None)The names under which some columns are shown, every column under its own name when omitted. Each
NameChangeapplies to the legend, the labels of boxes, heatmaps and missing value charts, the legends ofcolor_byandsize_by, and the default title and axis labels, on every chart of the Plot. The columns of an Array are named"0","1"... The values themselves, such as the parts of a pie, are never renamed. A title or a label given here keeps its text.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
InvalidRotationErrorWhen
x_tick_rotationory_tick_rotationis outside -90 to 90 degrees.
Examples:
import numdaplot as ndp
days = ndp.Array.from_list([1, 2, 3, 4])
prices = ndp.Array.from_list([12.0, 15.5, 14.0, 17.0])
costs = ndp.Array.from_list([8.0, 9.5, 9.0, 10.0])
sales = ndp.Table.from_arrays({"day": days, "price": prices, "cost": costs})
chart = ndp.LineChart(x="day", y=["price", "cost"])
style = ndp.PlotStyle(title="Sales", x_label="Day", y_label="Euros", legend=ndp.LegendPosition.OUTSIDE_RIGHT)
plot = ndp.Plot.line(sales, chart, style)
plot.show()
The labels of the x values can take another angle.
cities = ndp.Array.from_list(["Paris", "Lyon", "Marseille"])
totals = ndp.Array.from_list([120.0, 80.0, 95.0])
city_sales = ndp.Table.from_arrays({"city": cities, "total": totals})
city_chart = ndp.BarChart(x="city", y=["total"])
city_plot = ndp.Plot.bar(city_sales, city_chart, ndp.PlotStyle(x_tick_rotation=90))
city_plot.show()
The columns can be shown under other names, without renaming them in the Table.
shown_names = ndp.Renaming(changes=[ndp.NameChange(old_name="total", new_name="Total sales")])
named_plot = ndp.Plot.bar(city_sales, city_chart, ndp.PlotStyle(renaming=shown_names))
named_plot.show()