While creating data visualizations, there are often certain parts that are particularly important, and they may require some additional context.
Yet, this additional information may not be immediately obvious to the viewer.
A good data storyteller always ensures that:
The plot guides the viewer’s attention to these key areas.
The plot concisely provides any information needed for better interpretation.
One great (yet underrated) to provide extra info is by adding text annotations to a plot, as depicted below:
Such efforts always ensure that the plot indeed communicates what we intend it to depict — even if the plot’s creator is not present at that time.
In matplotlib, you can use 𝐚𝐧𝐧𝐨𝐭𝐚𝐭𝐞(), as depicted below:
It adds explanatory texts to your plot, which lets you guide a viewer’s attention to specific areas and aid their understanding.
Isn’t that cool?
You can find the Jupyter notebook for today’s newsletter here: Annotated plots notebook.
👉 Over to you: What are some other ways you use to enrich Matplotlib plots
Thanks for reading!
Are you preparing for ML/DS interviews or want to upskill at your current job?
Every week, I publish in-depth ML dives. The topics align with the practical skills that typical ML/DS roles demand.
Join below to unlock all full articles:
Here are some of the top articles:
[FREE] A Beginner-friendly and Comprehensive Deep Dive on Vector Databases.
A Detailed and Beginner-Friendly Introduction to PyTorch Lightning: The Supercharged PyTorch
Don’t Stop at Pandas and Sklearn! Get Started with Spark DataFrames and Big Data ML using PySpark.
Federated Learning: A Critical Step Towards Privacy-Preserving Machine Learning.
Sklearn Models are Not Deployment Friendly! Supercharge Them With Tensor Computations.
Deploy, Version Control, and Manage ML Models Right From Your Jupyter Notebook with Modelbit
Join below to unlock all full articles:
👉 If you love reading this newsletter, share it with friends!
👉 Tell the world what makes this newsletter special for you by leaving a review here :)
error in procedure two
IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed
The above exception was the direct cause of the following exception:
ConversionError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/matplotlib/axis.py in convert_units(self, x)
1732 ret = self.converter.convert(x, self.units, self)
1733 except Exception as e:
-> 1734 raise munits.ConversionError('Failed to convert value(s) to axis '
1735 f'units: {x!r}') from e
1736 return ret
ConversionError: Failed to convert value(s) to axis units: '2020-02-20'
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/matplotlib/axis.py in convert_units(self, x)
1731 try:
-> 1732 ret = self.converter.convert(x, self.units, self)
1733 except Exception as e:
19 frames
IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed
The above exception was the direct cause of the following exception:
ConversionError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/matplotlib/axis.py in convert_units(self, x)
1732 ret = self.converter.convert(x, self.units, self)
1733 except Exception as e:
-> 1734 raise munits.ConversionError('Failed to convert value(s) to axis '
1735 f'units: {x!r}') from e
1736 return ret
ConversionError: Failed to convert value(s) to axis units: '2020-02-20'
<Figure size 1300x600 with 1 Axes>