Area plot. Note: - When a single y_column is passed: Shade area between the y_values and zero. - Use `stacked` argument for stacked areas. - When both y_column and second_y_column are passed: Shade area between the two y_co
(
self,
data_frame,
x_column,
y_column,
second_y_column=None,
color_column=None,
color_order=None,
stacked=False,
)
| 528 | return self._chart |
| 529 | |
| 530 | def area( |
| 531 | self, |
| 532 | data_frame, |
| 533 | x_column, |
| 534 | y_column, |
| 535 | second_y_column=None, |
| 536 | color_column=None, |
| 537 | color_order=None, |
| 538 | stacked=False, |
| 539 | ): |
| 540 | """Area plot. |
| 541 | |
| 542 | Note: |
| 543 | - When a single y_column is passed: Shade area between the |
| 544 | y_values and zero. |
| 545 | - Use `stacked` argument for stacked areas. |
| 546 | - When both y_column and second_y_column are passed: |
| 547 | Shade area between the two y_columns. |
| 548 | |
| 549 | Args: |
| 550 | data_frame (pandas.DataFrame): Data source for the plot. |
| 551 | x_column (str): Column name to plot on the x axis. |
| 552 | y_column (str): Column name to plot on the y axis. |
| 553 | second_y_column (str, optional): Column name to plot on |
| 554 | the y axis. |
| 555 | color_column (str, optional): Column name to group by on |
| 556 | the color dimension. |
| 557 | color_order (list, optional): List of values within the |
| 558 | 'color_column' for specific sorting of the colors. |
| 559 | stacked (bool, optional): Stacked the areas. |
| 560 | Only applicable with a single y_column. |
| 561 | Default: False. |
| 562 | """ |
| 563 | # Vertical option only applies to density plots |
| 564 | vertical = self._chart.axes._vertical |
| 565 | |
| 566 | alpha = 0.2 |
| 567 | colors, color_values = self._get_color_and_order(data_frame, color_column, color_order) |
| 568 | |
| 569 | self._set_numeric_axis_default_format(data_frame, x_column, y_column) |
| 570 | |
| 571 | if color_column is not None: |
| 572 | data_frame = ( |
| 573 | data_frame.set_index([x_column, color_column]) |
| 574 | .reindex( |
| 575 | index=pd.MultiIndex.from_product( |
| 576 | [ |
| 577 | data_frame[x_column].unique(), |
| 578 | data_frame[color_column].unique(), |
| 579 | ], |
| 580 | names=[x_column, color_column], |
| 581 | ) |
| 582 | ) |
| 583 | .reset_index(drop=False) |
| 584 | .fillna(0) |
| 585 | ) |
| 586 | |
| 587 | if second_y_column is None and color_column is not None: |