I tried the following code (test_seaborn.py
):
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt matplotlib.style.use('ggplot') import seaborn as sns sns.set() df = sns.load_dataset('iris') sns_plot = sns.pairplot(df, hue='species', size=2.5) fig = sns_plot.get_figure() fig.savefig("output.png") #sns.plt.show()
But I get this error:
Traceback (most recent call last): File "test_searborn.py", line 11, in <module> fig = sns_plot.get_figure() AttributeError: 'PairGrid' object has no attribute 'get_figure'
I expect the final output.png
will exist and look like this:

How can I resolve the problem?
Related Posts:
- How to add title to seaborn boxplot
- pandas DataFrame “no numeric data to plot” error
- How to customize a scatter matrix to see all titles?
- Add Legend to Seaborn point plot
- Plotting multiple different plots in one figure using Seaborn
- Plot pie chart and table of pandas dataframe
- Add Legend to Seaborn point plot
- TypeError: ‘DataFrame’ object is not callable
- Modify the legend of pandas bar plot
- Plot correlation matrix using pandas
- Seaborn Lineplot Module Object Has No Attribute ‘Lineplot’
- Label axes on Seaborn Barplot
- Plot a histogram such that the total area of the histogram equals 1
- matplotlib: plot multiple columns of pandas data frame on the bar chart
- Pandas dataframe groupby plot
- alueError: ordinal must be >= 1
- how to sort pandas dataframe from one column
- How to reset index in a pandas dataframe? [duplicate]
- Constructing pandas DataFrame from values in variables gives “ValueError: If using all scalar values, you must pass an index”
- How to iterate over rows in a DataFrame in Pandas
- pandas read_json: “If using all scalar values, you must pass an index”
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- Showing an image with pylab.imshow()
- Pandas DataFrame Groupby two columns and get counts
- How to show all columns’ names on a large pandas dataframe?
- How to groupby based on two columns in pandas?
- ImportError: No module named matplotlib.pyplot
- How to deal with SettingWithCopyWarning in Pandas
- ImportError: No module named pandas
- TypeError: ‘Series’ objects are mutable, thus they cannot be hashed problemwith column
- ValueError: Length of values does not match length of index | Pandas DataFrame.unique()
- Save plot to image file instead of displaying it using Matplotlib
- Creating an empty Pandas DataFrame, then filling it?
- DataFrame constructor not properly called
- ImportError: Missing required dependencies [‘numpy’]
- How can I plot a confusion matrix? [duplicate]
- How to iterate over rows in a DataFrame in Pandas
- Pandas group-by and sum
- pandas: merge (join) two data frames on multiple columns
- Why do I get: “Length of values does not match length of index” error?
- why should I make a copy of a data frame in pandas
- Pandas, merging two dataframes on multiple columns, and multiplying result
- How to read a .xlsx file using the pandas Library in iPython?
- Matplotlib automatic legend outside plot
- Changing the “tick frequency” on x or y axis in matplotlib?
- matplotlib error – no module named tkinter
- ModuleNotFoundError: No module named ‘matplotlib’
- What is dtype(‘O’), in pandas?
- Pandas ‘count(distinct)’ equivalent
- ValueError: ‘object too deep for desired array’
- What does axis in pandas mean?
- How to add title to subplots in Matplotlib
- Combine two columns of text in pandas dataframe
- How to change a ‘LinearSegmentedColormap’ to a different distribution of color?
- Pandas: change data type of Series to String
- Normalize data in pandas
- Selecting with complex criteria from pandas.DataFrame
- How to make a 3D scatter plot in matplotlib
- module ‘pandas’ has no attribute ‘rolling_mean’
- How to draw vertical lines on a given plot in matplotlib
- Changing the “tick frequency” on x or y axis in matplotlib
- How can I set the aspect ratio in matplotlib?
- Count unique values using pandas groupby
- Ignoring NaNs with str.containsv
- python SyntaxError: invalid syntax %matplotlib inline
- Count unique values per groups with Pandas [duplicate]
- How to make a histogram from a list of data
- How do I change the figure size with subplots?
- ValueError: x and y must be the same size
- No numeric types to aggregate – change in groupby() behaviour?
- Solution for SpecificationError: nested renamer is not supported while agg() along with groupby()
- ValueError: Expected object or value when reading json as pandas dataframe
- How to check if a column exists in Pandas
- Scatter plot colorbar – Matplotlib
- Pandas error “Can only use .str accessor with string values”
- matplotlib: how to draw a rectangle on image
- bbox_to_anchor and loc in matplotlib
- How to get row number in dataframe in Pandas?
- How to put the legend out of the plot
- Matplotlib: TypeError: can’t multiply sequence by non-int of type ‘numpy.float64’
- RuntimeError: Invalid DISPLAY variable
- AttributeError: ‘Series’ object has no attribute ‘reshape’
- Coalesce values from 2 columns into a single column in a pandas dataframe
- Unknown format code ‘f’ for object of type ‘str’- Folium
- Find the unique values in a column and then sort them
- Pandas: sum up multiple columns into one column without last column
- Why do many examples use `fig, ax = plt.subplots()` in Matplotlib/pyplot/python
- Convert Pandas Column to DateTime
- Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support
- plot a circle with pyplot
- Converting Pandas dataframe into Spark dataframe error
- Must have equal len keys and value when setting with an iterable
- Difference between data type ‘datetime64[ns]’ and ‘
- Merging two DataFrames
- How do I tell Matplotlib to create a second (new) plot, then later plot on the old one?
- How to print a specific row of a pandas DataFrame?
- vectorize conditional assignment in pandas dataframe
- Convert list of dictionaries to a pandas DataFrame
- Python Pandas : pivot table with aggfunc = count unique distinct
- AttributeError: ‘Series’ object has no attribute ‘split’ error in sending emails