.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "recipes/chart_context/plot_positive_negative_regions.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_recipes_chart_context_plot_positive_negative_regions.py: Shade Positive and Negative Regions --------------------------- It can be useful to call out positive or negative areas within a chart, especially for growth rate visualizations. This is achieved using the ``shade_y`` instance and specifying the appropriate ``start``, ``end``, and ``color``. - Use 2 regions to define the positive and negative areas and use the ``color`` to indicate if it is positive (green) or negative (red) - It can be beneficial to fix the ``axis_min`` and ``axis_max`` as well so that the ``start`` and ``end`` values of the region are easier to define. .. GENERATED FROM PYTHON SOURCE LINES 12-45 .. raw:: html


.. code-block:: Python import pandas as pd from visualization_toolkit.helpers.plotly import chart, axis, series, shade_y fig = chart( pdf, x_axis=axis(column_name="fiscal_qy", label="Fiscal Quarter"), chart_series=[ series( column_name="yy", label="Y/Y Growth Rate", color="black", location="y1", shape="dash", ), ], y1_axis=axis(label="Growth Rate", axis_type="percent", axis_min=-0.2, axis_max=0.2), shaded_regions=[ shade_y( start=-0.2, end=0, color="red", ), shade_y( start=0, end=0.2, color="green", ), ], ) fig .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.023 seconds) .. _sphx_glr_download_recipes_chart_context_plot_positive_negative_regions.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_positive_negative_regions.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_positive_negative_regions.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_positive_negative_regions.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_