!pip install seaborn
import numpy
import pandas
import seaborn
import matplotlib.pyplot as plt
%config IPCompleter.greedy = True
%matplotlib inline
Basic Barplots Using Seaborn
seaborn.set(style="white", context="talk")
rs = numpy.random.RandomState(7)
# Set up the matplotlib figure
f, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(8, 6), sharex=True)
# Generate some sequential data
x = numpy.array(list("ABCDEFGHI"))
y1 = numpy.arange(1, 10)
seaborn.barplot(x, y1, palette="BuGn_d", ax=ax1)
ax1.set_ylabel("Sequential")
# Center the data to make it diverging
y2 = y1 - 5
seaborn.barplot(x, y2, palette="RdBu_r", ax=ax2)
ax2.set_ylabel("Diverging")
# Randomly reorder the data to make it qualitative
y3 = rs.choice(y1, 9, replace=False)
seaborn.barplot(x, y3, palette="Set3", ax=ax3)
ax3.set_ylabel("Qualitative")
# Finalize the plot
seaborn.despine(bottom=True)
plt.setp(f.axes, yticks=[])
plt.tight_layout(h_pad=3)
Pairplot Using Seaborn on in-built data
seaborn.set()
df = seaborn.load_dataset("iris")
seaborn.pairplot(df, hue="species")
Basic Pairplot on Inputed Data
seaborn.set()
seaborn.pairplot(data, hue="CATCHMENT")
Grouped Barplot on Inputed Data
Sol_data=pandas.read_csv("/home/kirtiman/Downloads/Solar Power- Train.csv")
Sol_data.describe()
seaborn.set(style="ticks")
seaborn.boxplot(x="Visibility", y="Power Generated", hue="Sky Cover", data=Sol_data, palette="PRGn")
seaborn.despine(offset=10, trim=True)
Grid Plot
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="ticks")
# Create a dataset with many short random walks
rs = np.random.RandomState(4)
pos = rs.randint(-1, 2, (20, 5)).cumsum(axis=1)
pos -= pos[:, 0, np.newaxis]
step = np.tile(range(5), 20)
walk = np.repeat(range(20), 5)
df = pd.DataFrame(np.c_[pos.flat, step, walk],
columns=["position", "step", "walk"])
# Initialize a grid of plots with an Axes for each walk
grid = sns.FacetGrid(df, col="walk", hue="walk", col_wrap=5, size=1.5)
# Draw a horizontal line to show the starting point
grid.map(plt.axhline, y=0, ls=":", c=".5")
# Draw a line plot to show the trajectory of each random walk
grid.map(plt.plot, "step", "position", marker="o", ms=4)
# Adjust the tick positions and labels
grid.set(xticks=np.arange(5), yticks=[-3, 3],
xlim=(-.5, 4.5), ylim=(-3.5, 3.5))
# Adjust the arrangement of the plots
grid.fig.tight_layout(w_pad=1)
In [1]:
!pip install seaborn
In [2]:
import numpy
import pandas
import seaborn
import matplotlib.pyplot as plt
%config IPCompleter.greedy = True
%matplotlib inline
Basic Barplots Using Seaborn¶
In [3]:
seaborn.set(style="white", context="talk")
rs = numpy.random.RandomState(7)
# Set up the matplotlib figure
f, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(8, 6), sharex=True)
# Generate some sequential data
x = numpy.array(list("ABCDEFGHI"))
y1 = numpy.arange(1, 10)
seaborn.barplot(x, y1, palette="BuGn_d", ax=ax1)
ax1.set_ylabel("Sequential")
# Center the data to make it diverging
y2 = y1 - 5
seaborn.barplot(x, y2, palette="RdBu_r", ax=ax2)
ax2.set_ylabel("Diverging")
# Randomly reorder the data to make it qualitative
y3 = rs.choice(y1, 9, replace=False)
seaborn.barplot(x, y3, palette="Set3", ax=ax3)
ax3.set_ylabel("Qualitative")
# Finalize the plot
seaborn.despine(bottom=True)
plt.setp(f.axes, yticks=[])
plt.tight_layout(h_pad=3)
Pairplot Using Seaborn on in-built data¶
In [4]:
seaborn.set()
df = seaborn.load_dataset("iris")
seaborn.pairplot(df, hue="species")
Out[4]:
Basic Pairplot on Inputed Data¶
In [5]:
seaborn.set()
seaborn.pairplot(data, hue="CATCHMENT")
Grouped Barplot on Inputed Data¶
In [6]:
Sol_data=pandas.read_csv("/home/kirtiman/Downloads/Solar Power- Train.csv")
In [7]:
Sol_data.describe()
Out[7]:
In [8]:
seaborn.set(style="ticks")
seaborn.boxplot(x="Visibility", y="Power Generated", hue="Sky Cover", data=Sol_data, palette="PRGn")
seaborn.despine(offset=10, trim=True)
Grid Plot¶
In [9]:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="ticks")
# Create a dataset with many short random walks
rs = np.random.RandomState(4)
pos = rs.randint(-1, 2, (20, 5)).cumsum(axis=1)
pos -= pos[:, 0, np.newaxis]
step = np.tile(range(5), 20)
walk = np.repeat(range(20), 5)
df = pd.DataFrame(np.c_[pos.flat, step, walk],
columns=["position", "step", "walk"])
# Initialize a grid of plots with an Axes for each walk
grid = sns.FacetGrid(df, col="walk", hue="walk", col_wrap=5, size=1.5)
# Draw a horizontal line to show the starting point
grid.map(plt.axhline, y=0, ls=":", c=".5")
# Draw a line plot to show the trajectory of each random walk
grid.map(plt.plot, "step", "position", marker="o", ms=4)
# Adjust the tick positions and labels
grid.set(xticks=np.arange(5), yticks=[-3, 3],
xlim=(-.5, 4.5), ylim=(-3.5, 3.5))
# Adjust the arrangement of the plots
grid.fig.tight_layout(w_pad=1)
In [ ]:
In [ ]:
No comments:
Post a Comment