To change the labels for Pandas df.plot()
use ax.legend([...])
:
import pandas as pd import matplotlib.pyplot as plt fig, ax = plt.subplots() df = pd.DataFrame({'A':26, 'B':20}, index=['N']) df.plot(kind='bar', ax=ax) #ax = df.plot(kind='bar') # "same" as above ax.legend(["AAA", "BBB"]);
Another approach is to do the same by plt.legend([...])
:
import matplotlib.pyplot as plt df.plot(kind='bar') plt.legend(["AAA", "BBB"]);
Related Posts:
- How do you change the size of figures drawn with Matplotlib?
- matplotlib savefig() plots different from show()
- Save plot to image file instead of displaying it using Matplotlib
- pandas DataFrame “no numeric data to plot” error
- How do you change the size of figures drawn with Matplotlib?
- How to customize a scatter matrix to see all titles?
- Matplotlib automatic legend outside plot
- Matplotlib automatic legend outside plot
- Changing the “tick frequency” on x or y axis in matplotlib?
- Plot pie chart and table of pandas dataframe
- TypeError: ‘DataFrame’ object is not callable
- How to add title to subplots in Matplotlib
- Create own colormap using matplotlib and plot color scale
- How to make a 3D scatter plot in matplotlib
- Changing the “tick frequency” on x or y axis in matplotlib
- Remove xticks in a matplotlib plot?
- How to add title to seaborn boxplot
- How to save a Seaborn plot into a file
- Plot correlation matrix using pandas
- Scatter plot colorbar – Matplotlib
- Plotting multiple lines, in different colors, with pandas dataframe
- Why do many examples use `fig, ax = plt.subplots()` in Matplotlib/pyplot/python
- matplotlib: plot multiple columns of pandas data frame on the bar chart
- Pandas dataframe groupby plot
- How do I tell Matplotlib to create a second (new) plot, then later plot on the old one?
- alueError: ordinal must be >= 1
- ImportError: DLL load failed: The specified module could not be found
- Renaming column names in Pandas
- Delete a column from a Pandas DataFrame
- What is the difference between importing matplotlib and matplotlib.pyplot?
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- Adding new column to existing DataFrame in Python pandas
- Modifing data while using iterrows() does not work
- How to change the order of DataFrame columns?
- Is “from matplotlib import pyplot as plt” == “import matplotlib.pyplot as plt”?
- What does `ValueError: cannot reindex from a duplicate axis` mean?
- _tkinter.TclError: no display name and no $DISPLAY environment variable
- How to fix IndexError: invalid index to scalar variable
- Create a Pandas Dataframe by appending one row at a time
- How do I select rows from a DataFrame based on column values?
- How do I get the row count of a Pandas DataFrame?
- How to plot a histogram using Matplotlib in Python with a list of data?
- Convert pandas dataframe to NumPy array
- In Matplotlib, what does the argument mean in fig.add_subplot(111)?
- Error:cannot convert float NaN to integer in pandas
- Replacing column values in a pandas DataFrame
- Unable to plot Double Bar, Bar plot using pyplot for ndarray
- matplotlib error – no module named tkinter
- How do I get the row count of a Pandas DataFrame?
- Pandas “Can only compare identically-labeled DataFrame objects” error
- Get list from pandas dataframe column or row?
- ‘DataFrame’ object has no attribute ‘sort’
- TypeError: cannot unpack non-iterable int objec
- Pandas DataFrame column to list
- Rename Pandas DataFrame Index
- How do I set the figure title and axes labels font size in Matplotlib?
- Convert DataFrame column type from string to datetime, dd/mm/yyyy format
- Is there a list of line styles in matplotlib?
- Get a list from Pandas DataFrame column headers
- Plotting multiple different plots in one figure using Seaborn
- Change figure size and figure format in matplotlib
- Python TypeError: cannot convert the series to
when trying to do math on dataframe - Shuffle DataFrame rows
- Overcome ValueError for empty array
- Using %matplotlib notebook after %matplotlib inline in Jupyter Notebook doesn’t work
- Display image as grayscale using matplotlib
- How to iterate over columns of pandas dataframe to run regression
- JSON to pandas DataFrame
- Converting between datetime and Pandas Timestamp objects
- Creating a Pandas DataFrame from a Numpy array: How do I specify the index column and column headers?
- Map to List error: Series object not callable
- Pandas DataFrame: replace all values in a column, based on condition
- How to convert string to datetime format in pandas python?
- Pandas – How to flatten a hierarchical index in columns
- raise LinAlgError(“SVD did not converge”) LinAlgError: SVD did not converge in matplotlib pca determination
- Pandas OR statement ending in series contains
- TypeError: Invalid dimensions for image data when plotting array with imshow()
- matplotlib does not show my drawings although I call pyplot.show()
- How to get a value from a cell of a dataframe?
- Groupby value counts on the dataframe pandas
- How to plot an array in python?
- Pandas index column title or name
- Building multi-regression model throws error: `Pandas data cast to numpy dtype of object. Check input data with np.asarray(data).`
- import pandas_datareader gives ImportError: cannot import name ‘is_list_like’
- How to add pandas data to an existing csv file?
- Importing Pandas gives error AttributeError: module ‘pandas’ has no attribute ‘core’ in iPython Notebook
- Plot a histogram such that the total area of the histogram equals 1
- How to change legend size with matplotlib.pyplot
- cannot convert the series to
- An equivalent function to matplotlib.mlab.bivariate_normal
- How to convert index of a pandas dataframe into a column
- Replacing Pandas or Numpy Nan with a None to use with MysqlDB
- pandas replace multiple values one column
- Convert floats to ints in Pandas?
- pandas comparison raises TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
- Plotting a python dict in order of key values
- MovieWriter ffmpeg unavailable; trying to use class ‘matplotlib.animation.PillowWriter’ instead
- Extract first and last row of a dataframe in pandas
- Error in Reading a csv file in pandas[CParserError: Error tokenizing data. C error: Buffer overflow caught – possible malformed input file.]
- Extracting specific selected columns to new DataFrame as a copy