我目前正致力于用Seaborn和Pandas可视化数据集。我有一些与时间有关的数据,我想用条形图来表示。
然而,我在海运业面临两个问题:
X轴上的格式化日期。
只显示少量的日期(因为在一个6个月的图表上标记每一天是没有意义的)
我在普通Matplotlib中找到了解决问题的方法,即:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import numpy as np
N = 20
np.random.seed
AttributeError:'bool‘对象在我的Python数据分析中没有'all’属性,我正在尝试使用pandas/matplotlib添加给定某个国家的泥石流数据的死亡总数。然后,我想使用seaborn将数据可视化到柱状图上。然而,每当我这样做的时候,我都会得到一个AttributeError:'bool‘对象没有'all’属性的错误。我正在使用的CSV文件可以在这里找到:到目前为止,这是我的代码。
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns
我正在绘制水平条形图。它工作,但颜色是彩虹风格。如何将每个条形的颜色更改为相同的颜色?
%pyspark
import seaborn as sns
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
plt.clf()
sns.set_context("notebook", font_scale=0.5)
# plot barchart by x axis and use different color for day
sns.barplot(x = "sc
当我尝试在jupyter笔记本中使用seaborn绘制双轴绘图时,我遇到了一个问题:代码在Python2中工作得非常好。 在使用anaconda升级到Python 3之后,我得到了愚蠢的错误消息: /Users/enyi/opt/anaconda3/lib/python3.7/site-packages/seaborn/categorical.py:3720: UserWarning: catplot is a figure-level function and does not accept target axes. You may wish to try countplot
warn
我想把重复的剖面线图案添加到一个海运桶图上。 当然,我检查了下面的问答,但我无法解决我的问题。 Is it possible to add hatches to each individual bar in seaborn.barplot? 在上面的问答中,不同的补丁图案应用于左边的蓝色('-')和右边的蓝色('+')。我希望将相同的补丁图案应用于相同的颜色条;("//")应应用于两个蓝色条,("\")应应用于两个绿色条,而("|")应应用于两个红色条。 我试过下面的代码,但我不能实现我理想的身材。 import
我希望列的颜色取决于它们在x轴上的值,例如在x轴上具有相同值的条形线应该有相同的颜色分配给它们。
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
df = pd.DataFrame(index=['A','B','C','D','E','F'],data={'col1':np.array([2.3423,4.435,9.234,9.234,2.
在下面的代码中,Matplotlib给出了5.0到10.0的正确范围,为什么Seaborn是不同的呢?
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from matplotlib import ticker
sns.set()
fig, (ax1, ax2) = plt.subplots(2)
x = np.linspace(5, 10)
y = x ** 2
sns.barplot(x, y, ax=ax1)
ax1.xaxis.set_major_locator(ticker.Mu
我试图使用matplotlib / seaborn将数据标签添加到双轴图的一部分,但似乎找不到让标签显示的解决方案。
# Pandas for managing datasets
import pandas as pd
# Matplotlib for additional customization
from matplotlib import pyplot as plt
%matplotlib inline
# Seaborn for plotting and styling
import seaborn as sns
# Sample data
data = {'Perfo
我尝试在Python语言中使用几个不同的库(bokeh、seaborn和matlotlib)绘制图形,但保持相同的配色方案。我已经从bokeh中选择了分类调色板:
from bokeh.palettes import Category10 as palette
然后还在seaborn和matplotlib中使用了它。我的问题是,尽管在matplotlib中的颜色看起来与bokeh非常相似(在调色板中定义),但seaborn显示的颜色在某种程度上比它应该显示的更暗(即不那么饱和或不饱和)。我想知道它是否在默认情况下使任何配色方案变暗,以及是否有任何方法可以避免这种情况。下面是使用不同的库制作相同
背景
我正在阅读“用Python进行机器学习介绍”,并尝试在中实现的可视化。首先,我使用不同的LogisticRegression参数为Winsconsin癌症数据集安装了3个C分类器。然后,对于每个分类器,我绘制了每个特征的系数大小。
%matplotlib inline
from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from matplotlib import pyplot as plt
cancer = load_breast_can
我使用下面的代码创建了一个Seaborn条形图(它来自https://www.machinelearningplus.com/plots/top-50-matplotlib-visualizations-the-master-plots-python/) 我希望所有的栏堆叠起来没有空格,但一直无法做到这一点。如果我添加width,它会报告barh中的width有多个值。这可能是因为seaborn有自己的算法来确定宽度。它周围有没有呢? import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# Re
我正在尝试创建一个按性别分组的人口金字塔。不幸的是,我不能让它工作。这个图只是一幅白色的图画,轴线似乎颠倒了。也许有人能帮我,谢谢。 import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# I read this testdata from a csv file
testdata = pd.DataFrame({'age': [20, 20, 21, 21, 22, 22, 23, 23],
'gender': ["male