Line Chart. Note: This method will not automatically sort the x-axis. Try sorting the axis if the line graph looks strange. Args: data_frame (pandas.DataFrame): Data source for the plot. x_column (str): Column name to plot on the x ax
(
self,
data_frame,
x_column,
y_column,
color_column=None,
color_order=None,
line_dash="solid",
line_width=4,
alpha=1.0,
)
| 303 | """ |
| 304 | |
| 305 | def line( |
| 306 | self, |
| 307 | data_frame, |
| 308 | x_column, |
| 309 | y_column, |
| 310 | color_column=None, |
| 311 | color_order=None, |
| 312 | line_dash="solid", |
| 313 | line_width=4, |
| 314 | alpha=1.0, |
| 315 | ): |
| 316 | """Line Chart. |
| 317 | |
| 318 | Note: |
| 319 | This method will not automatically sort the x-axis. |
| 320 | Try sorting the axis if the line graph looks strange. |
| 321 | |
| 322 | Args: |
| 323 | data_frame (pandas.DataFrame): Data source for the plot. |
| 324 | x_column (str): Column name to plot on the x axis. |
| 325 | y_column (str): Column name to plot on the y axis. |
| 326 | color_column (str, optional): Column name to group by on |
| 327 | the color dimension. |
| 328 | color_order (list, optional): List of values within the |
| 329 | 'color_column' for specific sorting of the colors. |
| 330 | line_dash (str, optional): Dash style for the line. One of: |
| 331 | - 'solid' |
| 332 | - 'dashed' |
| 333 | - 'dotted' |
| 334 | - 'dotdash' |
| 335 | - 'dashdot' |
| 336 | line_width (int, optional): Width of the line |
| 337 | alpha (float): Alpha value. |
| 338 | """ |
| 339 | settings = self._chart.style._get_settings("line_plot") |
| 340 | line_cap = settings["line_cap"] |
| 341 | line_join = settings["line_join"] |
| 342 | |
| 343 | colors, color_values = self._get_color_and_order(data_frame, color_column, color_order) |
| 344 | |
| 345 | self._set_numeric_axis_default_format(data_frame, x_column, y_column) |
| 346 | |
| 347 | for color_value, color in zip(color_values, colors): |
| 348 | if color_column is None: # Single line |
| 349 | sliced_data = data_frame |
| 350 | else: |
| 351 | sliced_data = data_frame[data_frame[color_column] == color_value] |
| 352 | # Filter to only relevant columns. |
| 353 | sliced_data = sliced_data[ |
| 354 | [col for col in sliced_data.columns if col in (x_column, y_column, color_column)] |
| 355 | ] |
| 356 | |
| 357 | cast_data = self._cast_datetime_axis(sliced_data, x_column) |
| 358 | |
| 359 | source = self._named_column_data_source(cast_data, series_name=color_value) |
| 360 | |
| 361 | color_value = str(color_value) if color_value is not None else color_value |
| 362 |
nothing calls this directly
no test coverage detected