Skip to content
Advertisement

Tag: matplotlib

Add x and y labels to a pandas plot

Suppose I have the following code that plots something very simple using pandas: How do I easily set x and y-labels while preserving my ability to use specific colormaps? I noticed that the plot() wrapper for pandas DataFrames doesn’t take any parameters specific for that. Answer In Pandas version 1.10 you can use parameters xlabel and ylabel in the method

Python ASCII plots in terminal

With Octave I am able to plot arrays to the terminal, for example, plotting an array with values for the function x^2 gives this output in my terminal: Is there some way I can do something similar in Python, specifically with matplotlib? bashplotlib seems to offer some of this functionality but appears to be quite basic compared to Octave’s offering.

Matplotlib connect scatterplot points with line – Python

I have two lists, dates and values. I want to plot them using matplotlib. The following creates a scatter plot of my data. plt.plot(dates, values) creates a line graph. But what I really want is a scatterplot where the points are connected by a line. Similar to in R: , which gives me a scatterplot of points overlaid with a

How to save the Pandas dataframe/series data as a figure?

It sounds somewhat weird, but I need to save the Pandas console output string to png pics. For example: Is there any way like df.output_as_png(filename=’df_data.png’) to generate a pic file which just display above content inside? Answer Option-1: use matplotlib table functionality, with some additional styling: Options-2 Use Plotly + kaleido For the above, the font size can be changed

Matplotlib – How to remove a specific line or curve

I want to remove a specific line in a plot of multiple lines. Bellow is a given example which is not sufficient for me because it removes only the last plotted line and not the line that I want to remove. How can I do that? How can I address a specific line(by name, by number, by reference) throughout the

sklearn plot confusion matrix with labels

I want to plot a confusion matrix to visualize the classifer’s performance, but it shows only the numbers of the labels, not the labels themselves: How can I add the labels (health, business..etc) to the confusion matrix? Answer As hinted in this question, you have to “open” the lower-level artist API, by storing the figure and axis objects passed by

Boxplots in matplotlib: Markers and outliers

I have some questions about boxplots in matplotlib: Question A. What do the markers that I highlighted below with Q1, Q2, and Q3 represent? I believe Q1 is maximum and Q3 are outliers, but what is Q2?                        Question B How does matplotlib identify outliers? (i.e. how does it know that they are not the true max and min values?)

Advertisement