How to fix matplotlib and seaborn heatmap plot?
Date : March 29 2020, 07:55 AM
Does that help Unfortunately you don't show any code for the matplotlib plot. But the solution to get rid of the grid is to use plt.grid(False).
|
Plot duration in matplotlib / seaborn
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I want to plot the results of a 5K and a 10K run in Python with matplotlib and seaborn. My dataset has a column time that contains a string object in a HH:MM:SS format, like 00:28:50 or 1:17:23, with the race results. I created my plot by calculating the time in seconds, but I prefer the actual time in HH:MM:SS format on the axis for readability. , One thing you could do is to modify the ticks manually: order=['5K', '10K']
palette = ['#3498db', '#ff0080']
fig, ax = plt.subplots(figsize=(16, 8))
sns.boxplot(ax=ax, data=df, x='time_sec', y='race', hue='sex', order=order, palette=palette, orient='h', linewidth=2.5)
# get the ticks
ticks = ax.get_xticks()
# convert the ticks to string
ax.set_xticklabels(pd.to_datetime(ticks, unit='s').strftime('%H:%M:%S'))
plt.title('Time in seconds', fontsize=16)
plt.show()
|
Python matplotlib/seaborn plot bar chart subcategories
Date : March 29 2020, 07:55 AM
Hope this helps I have a dictionary of dictionaries called data. I want to plot a bar chart so that each of A, B, C, and D have a value for the pos and neg. %matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
data = {'A': {'pos': 289794, 'neg': 515063},
'B': {'pos': 174790, 'neg': 292551},
'C': {'pos': 375574, 'neg': 586616},
'D': {'pos': 14932, 'neg': 8661}}
df = pd.DataFrame(data)
df = df.T
df ['sum'] = df.sum(axis=1)
df.sort_values('sum', ascending=False)[['neg','pos']].plot.bar()
|
How can I plot a categorical feature vs categorical values in python using seaborn or matplotlib
Date : March 29 2020, 07:55 AM
With these it helps How can I plot a bar graph for categorical feature containing values male and female to another column containing binary values like 0 and 1 such that x axis contains the male and female whereas y axis contains the number of values of 0 and 1 corresponding to male and female on y axis. df.unstack().plot.bar(stacked=False)
df.unstack().plot.barh(stacked=False)
|
Python Matplotlib/Seaborn/Jupyter - Putting bar plot in wrong place?
Date : March 29 2020, 07:55 AM
This might help you You see two axes in Jupyter because you create a fresh one with plt.subplots() and pandas also creates another one. If you need to reuse an existing axe, pass it to plotting method using ax switch: fig, axe = plt.subplots()
freq.to_frame().T.plot.barh(stacked=True, ax=axe)
axe = freq.to_frame().T.plot.barh(stacked=True)
|