- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个大数据集,我想在 seaborn 中将其绘制为线图。
我的数据集由不同数据中特定植物的不同测量值组成,所以基本上我想将数据集中的每一行绘制为折线图中的一条线,正如我在这张图片中尝试展示的那样:
为了这个目标,我尝试在下一个代码中使用 seaborn:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
####THERE WAS MORE PROCESSING OF THE DATA THAT I BELIEVE IS IRRELEVANT
####Here I have tried to determine what I want in my axis. I haven't really use the value wavelength
#X axis
wavelength=new_db.columns.values[5:]
#y axis- values
#basically the outcome of this suppose to be a table with only values when ach row represents a hour
colum=new_db.columns.tolist()
new_db=new_db[cols[1:]]
#here i'm trying to create the plot
sns.set(style="whitegrid")
sns.lineplot(data=new_db, palette="tab10", linewidth=2.5)
#ERROR
ValueError: These
style
levels are missing dashes: set(['747.5', '814.81', '842.44', '906.34', '433.71', '667.2', '431.09', '512.97', '850.75', '882.67', '751.61', '911.92', '601.11', '847.98', '917.5', '828.61', '679.4', '440.29', '705.21', '729.74', '421.9', '959.5', '648.26', '956.69', '446.87', '445.55', '727.01', '605.14', '506.33', '856.29', '531.58', '889.63', '576.97', '924.49', '503.68', '897.98', '707.93', '970.73', '953.89', '839.67', '510.31', '678.04', '772.17', '473.24', '659.08', '813.43', '442.92', '781.78', '688.9', '623.98', '684.82', '634.76', '834.14', '955.29', '575.63', '589.03', '817.57', '474.56', '638.81', '935.68', '454.77', '571.62', '871.55', '587.69', '987.61'...............
(原始消息更长,数字更多。)
我也试过用这个来创建它:
sns.set(style="whitegrid")
ax = sns.lineplot(x="wavelength", y="new_db")
但是出现了这个错误:
ValueError: Could not interpret input 'wavelength'
我不知道怎么解决。
这是我最终想要得到的产品:
最佳答案
转置你的 DataFrame 怎么样?
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.DataFrame(np.random.rand(3, 10)).T
print(df)
数据框:
0 1 2
0 0.341005 0.925077 0.541746
1 0.324769 0.558320 0.902804
2 0.647871 0.630663 0.607212
3 0.722298 0.745091 0.630445
4 0.209836 0.386576 0.076790
5 0.347911 0.237178 0.446102
6 0.174991 0.777129 0.109934
7 0.022564 0.388223 0.464438
8 0.359771 0.722761 0.837942
9 0.091696 0.474859 0.840078
情节
sns.lineplot(data=df.iloc[:, :2])
结果:
关于python - 从数据集在 seaborn 的线图中创建多条线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59375456/
如何从 seaborn 生成的热图中隐藏颜色条 import numpy as np; np.random.seed(0) import seaborn as sns; sns.set_theme()
我正在尝试使用 seaborn 制作热图,但被困在更改特定值的颜色。假设值 0 应该是白色,值 1 应该是灰色,然后使用 cmap 提供的调色板。 试图使用面具,但感到困惑。 import matpl
我想改变散点的大小。 这些都不起作用: sns.relplot(x='columnx', y='columny', hue='cluster', data=df) sns.relplot(x='col
这个问题在这里已经有了答案: What is y axis in seaborn distplot? (3 个答案) 关闭 3 年前。 我正在使用以下语句绘制分布图: a = sns.distplo
我注意到 sns.barplot 使用标准错误作为误差条默认 1 。有办法把它改成SD吗? ax = sns.barplot(x="day", y="tip", data=tips, ci=???)
向 seaborn FacetGrid 中的每个直方图添加表示平均值(或其他集中趋势度量)的点和可变性度量(例如,标准偏差或置信区间)的最佳方法是什么? 结果应该类似于显示的图 here ,但在每个
我正在尝试使用 sns.histplot() 而不是 sns.distplot() 因为我在 colab 中收到以下消息: FutureWarning: distplot is a deprecate
我想绘制 3 个水平条形图,标签作为 y 轴,数据作为 x 轴,我希望每个图都是不同的颜色,并有某种类型的注释,例如星号,这取决于关于数据中某列所表示的重要性,例如: dat = pd.DataFra
根据 seaborn 文档 here seaborn.distplot()已被弃用,向前支持的图是:seaborn.displot()和 seaborn.histplot() . 但是,当我尝试使用
为了使 seaborn.pairplot() 正常工作,在 jupyter notebook 中执行了以下步骤。 /usr/local/lib/python2.7/site-packages/matp
使用 pandas 数据框绘制混淆矩阵时 y 轴两端被切一半? 这就是我得到的: 我使用了这里的代码How can I plot a confusion matrix?使用 pandas 数据框: i
您好,我刚刚为 seaborn 热图创建了自定义 cmap,但是当我想使用它时,它没有显示正确的颜色。我已经一步一步完成了: import seaborn as sns import numpy as
亲爱的,我正在尝试将 kaggle 教程代码应用于 Iris 数据集。 不幸的是,当我执行图表的代码时,我只能看到这个输出而看不到任何图表: matplotlib.axes._subplots.Axe
这个问题在这里已经有了答案: Seaborn plots in a loop (6 个答案) How to plot in multiple subplots (12 个答案) 关闭 1 年前。 我
我正在尝试在 python 中使用 seaborn 绘制直方图。但它给我的只是一个空白数字。 这是我专栏的describe(): 代码: plt.subplots(figsize=(7,7)) sns
如何在seaborn.lineplot中分别设置标记和线条的透明度? 我有一组点,我想画一条连接所有点的线图。我希望线条比标记更透明。如何做到这一点? 这是我的目标: 这是我的代码: import m
我正在使用 seaborn 库在 python 中绘制热图。数据框包含一些缺失值 (NaN)。我希望与这些字段对应的热图单元格是白色的(默认情况下)并且还用字符串 NA 进行注释。但是,如果我看对了,
如何对这个图进行排序以从大到小显示?我尝试使用 sort_values 但不起作用 plt.figure(figsize=(15,8)) sns.countplot(x='arrival_date_m
我的目标是在使用 seaborn 绘制的图上的 y = 0 上绘制一条水平红线:sns.lmplot由 col= 分割或 row= . import numpy as np, seaborn as s
我正在使用seaborn pairplot绘制我的数据点不同维度的散点图。但是,我希望数据点的标记具有与数据点的维度之一相对应的大小。我有以下代码: markersize = 1000* my_dat
我是一名优秀的程序员,十分优秀!