Use Gemini to Make Charts
Visualizing data can be cumbersome, regardless of whether Excel, Python, R, Tableau, or another platform is doing the work. While it is rewarding work, there is definitely a learning curve. Thankfully, we can make Gemini our visualization assistant and have it help us discover specific techniques and produce plots for us.
Let’s use matplotlib and Python as our vehicle to make charts, although Gemini can certainly generate charting code for other platforms, given there is sufficient training data. Thankfully, matplotlib code is plentiful and mature so this should make Gemini effective on many asks.
Let’s say we wanted to plot a normal distribution with a mean of 14 and a standard deviation of 1:
Prompt: Can you use matplotlib and Python to show a normal distribution with a mean of 14.005 and a standard deviation of 0.955?
Gemini: Sure. Here is a Python code using matplotlib to show a normal distribution with a mean of 14.005 and a standard deviation of 0.955:
importmatplotlib.pyplotaspltimportnumpyasnp# Define the mean and standard deviationmean=14.005sd=0.955# Generate a normal distribution with the specified mean and standard deviationx=np.random.normal(mean,sd,10000)# Plot the normal distributionplt.hist(x,bins=50,density=True)plt.xlabel('Value')plt.ylabel('Probability')plt.title('Normal distribution with mean ={}and standard deviation ={}'.format(mean,sd))
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access