.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "recipes/pivoting/plot_pivot_chart_comparison.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_pivoting_plot_pivot_chart_comparison.py: Pivot Charts without Stacking --------------------------- Plotting charts where the input data is aggregated by a categorical column can be pivoted using ``pivot_column_name`` in the ``series`` function. When pivoting and wanting to compare series per point on the x-axis horizontally: - Each category can be manually plotted as a ``series`` by specifying the ``category_name`` parameter as the value along with the ``pivot_column_name`` to use for the series - The ``column_name`` should remain the numerical column to plot. The data will for the series will be filtered to the specific ``category_name`` automatically - The ``is_stacked`` parameter should be set to ``False`` or not set, as this is the default behavior - The order of the series in the legend and in the graph is based on the order of elements in ``chart_series`` parameter. .. GENERATED FROM PYTHON SOURCE LINES 15-50 .. raw:: html


.. code-block:: Python import pandas as pd from visualization_toolkit.helpers.plotly import chart, axis, series fig = chart( pdf, x_axis=axis(column_name="fiscal_qy", label="Fiscal Quarter"), y1_axis=axis(label="Downloads", axis_type="number", axis_min=0), chart_series=[ series( column_name="ios_dl_idx", category_name="UCAN", color="light-blue", mode="bar", pivot_column_name="region", ), series( column_name="ios_dl_idx", category_name="China", color="light-grey", mode="bar", pivot_column_name="region", ), series( column_name="ios_dl_idx", category_name="India", color="orange", mode="bar", pivot_column_name="region", ), ], ) fig .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.024 seconds) .. _sphx_glr_download_recipes_pivoting_plot_pivot_chart_comparison.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_pivot_chart_comparison.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_pivot_chart_comparison.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_pivot_chart_comparison.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_