plot
Returns a PySparkPlotAccessor for plotting functions.
You can create plots in two ways:
- Chaining style:
df.plot.line(...) - Explicit style:
df.plot(kind="line", ...)
Returns
plot.core.PySparkPlotAccessor
Examples
Python
data = [("A", 10, 1.5), ("B", 30, 2.5), ("C", 20, 3.5)]
columns = ["category", "int_val", "float_val"]
df = spark.createDataFrame(data, columns)
type(df.plot)
# <class 'pyspark.sql.plot.core.PySparkPlotAccessor'>
df.plot.line(x="category", y=["int_val", "float_val"])
df.plot(kind="line", x="category", y=["int_val", "float_val"])