Organizing Plots in Seaborn Pairplot - python

I've got a pandas dataframe with a bunch of values in and I want to plot each axis against each axis to get plots of every column against one another. Furthermore, I'm having an issue of the values of my y axis being so condensed that's it's unreadable. I've tried changing the height but have no clue how to "clean up" this axis.
Here is my plotting code:
import seaborn as sns
grid = sns.pairplot(df_merge, dropna = True, height=1.5)
Then here is the graph that has been plotted.

Related

How do I print scatter plots in a pandas column?

I created a pandas dataframe using the below code. (See the extra code and plt.show() which is there to create a new plot every time or else we get one plot with all of them in the same plot)
%matplotlib inline
pd.DataFrame(
np.array([[
col,
plt.scatter(data[col], data['SalePrice']) and plt.show()]
for col in data.columns]),
columns=['Feature', 'Scatter Plot']
)
But what I get is this
And at the end of the dataframe, I get all the scatter plots separately.
What I want is, for those graphs to get printed inline, inside the columns, just like the other values.

How do you change the spread of the Y axis of pandas box plot?

I am plotting 100 data points for 9 different groups. One group's data points are much larger than all the other groups so when I make a box graph using pandas only that group is shown, while all other groups are smashed to the bottom. Here is what it looks like now: smushed box plot
I would like the Y axis to be more spaced out so that I can see the other groups' box graphs. Here is similar data in a scatter plot that has the spacing I am looking for: well spaced scatter plot
What I have
What is need
Here is my code at the moment:
# use ``` to designate a code block in markdown
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("residues.csv")
df.plot.box()
plt.show()
It looks like you want y to be log-scaled:
df.plot.box(logy=True)
Try this:
boxplot = df.boxplot(column=df.columns)
plt.show()
Reference
See the pandas documentation on boxplot: https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.boxplot.html

How to plot certain row and column using panda dataframe?

I have a very simple data frame but I could not plot a line using a row and a column. Here is an image, I would like to plot a "line" that connects them.
enter image description here
I tried to plot it but x-axis disappeared. And I would like to swap those axes. I could not find an easy way to plot this simple thing.
Try:
import matplotlib.pyplot as plt
# Categories will be x axis, sexonds will be y
plt.plot(data["Categories"], data["Seconds"])
plt.show()
Matplotlib generates the axis dynamically, so if you want the labels of the x-axis to appear you'll have to increase the size of your plot.

Matplotlib Interactive subplots with integers and dates on X axes

I am trying to create two interactive plots where the first plot is simply a plot of x and y and the second plot is a subplot which plots dates (fulldate) on its x axis, which correspond to the integer values of x (x axis values) from the first plot.
This code almost does what I want. The only problem is that the dates are not linked to the integers, so when I use the zoom function on the graph, it zooms into the first plot and the subplot is linked and zooms also, but the dates stay stationary and therefore are completely inaccurate.
note that this is just a simplified version of my program. i will be rearranging the dates on the bottom display to got on the bottom.
The integers and the dates must be linked because in my actual program i will be using integers to keep count of the days in the time series.
import matplotlib.pyplot as plt
import seaborn as sns
x=[1,5,7,4,6]
y=[1,3,8,4,6]
fulldate=['01/01/2018','02/01/2018','03/01/2018','04/01/2018','05/01/2018']
with sns.axes_style("darkgrid"):
ax1=plt.subplot2grid((6,1),(0,0),rowspan=3,colspan=1)
ax2=plt.subplot2grid((6,1),(4,0),rowspan=1,colspan=1,sharex=ax1)
ax2v = ax2.twiny()
ax1.plot(x,y)
ax2v.fill_between(fulldate,'Dates')
for label in ax2v.xaxis.get_ticklabels():
label.set_rotation(60)

how to overlay a pandas plot, matplotlib plot, and axis

I have one plot in the format:
df.plot()
The other one is in the format:
fig,ax=plt.subplots()
ax.plot_date(t,y,'b-')
I cannot convert the first plot into the standard matplotlib plot because it is resampled from a pandas timeseries.
How do I overlay the two plots?
Try df.plot(ax=ax). This causes the dataframe object to be plotted in the supplied axis.

Categories