仅当恰好在栏内单击时才会触发“单击”事件。如果我们有一个宽度或高度较小的条形,这并不方便。当我将鼠标悬停在栏上时,栏周围的一些空间会以完整的图表高度突出显示,并显示工具提示。我想让突出显示的区域可点击,并且条形数据应该在事件中可用。我已经阅读了文档并尝试了 Chart.on('click', 'xAxis.category', function () {...}); 但该功能没有被触发。
在此演示中,仅当我在栏内单击时才会触发警报。如何使周围区域可点击?
https://codesandbox.io/s/cocky-banzai-6j5pg?file=/src/Chart.js
我已经看过许多在 Python 中使用 matplotlib/seaborn 进行 3D 绘图的示例,但似乎无法得到我正在寻找的东西;我有 50 个左右的时间序列,我想将它们清晰地绘制出来,如下例所示,但在轴上使用系列名称;作为我在 Goog、IBM、GE、百事可乐等中标记的示例。感谢任何指示或示例。谢谢你,
python data-visualization matplotlib timeserieschart seaborn
有没有办法控制水平线和垂直线的起点和终点plotly?
import plotly.graph_objects as go
fig = go.Figure(data=go.Scatter())
fig.add_vline(x=1, line_width=2, line_dash="dash", line_color="green")
fig.add_hline(y=2, line_width=2, line_dash="dash", line_color="red")
fig.show()
Run Code Online (Sandbox Code Playgroud)
上面的代码将绘制线条,但在整个屏幕上
我想做类似的事情:
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize = (10,7))
ax.hlines(y=2, xmin='July', xmax='Aug', linewidth=2, color='red', linestyles = 'dotted')
ax.axvline(x = 1,color = 'green', linestyle = 'dotted', linewidth = 2)
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 R 中画一个正方形:
ggplot() +
geom_rect(aes(xmin = 1, xmax = sqrt(pi), ymin = 1, ymax = sqrt(pi)))
Run Code Online (Sandbox Code Playgroud)
但这会产生一个看起来更像矩形的形状 - 我认为这是因为缩放比例不正确?
有人可以告诉我如何解决这个问题吗?
我正在用Python学习乳腺癌分类数据集。我正在尝试为每个特征绘制直方图,如何将这些直方图分为三组?就像下面的截图一样:

这是我使用的代码:
from sklearn.datasets import load_breast_cancer # sample data
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
data = load_breast_cancer()
# Turn the feature data into a dataframe
df = pd.DataFrame(data.data, columns = data.feature_names)
# Add the target columns, and fill it with the target data
df["target"] = data.target
# display(df.head())
mean radius mean texture mean perimeter mean area mean smoothness mean compactness mean concavity mean concave points mean symmetry mean fractal dimension radius error …Run Code Online (Sandbox Code Playgroud) ax.set_axisbelow(True)可以使用或plt.rc('axes', axisbelow=True)(其他堆栈问题)将网格线设置在填充区域的图后面。但使用时alpha<1网格线也会出现在前面。有没有办法仍然隐藏网格线或应用选择性alpha混合?我正在考虑一种基于对象的方法,其中指定对象 a 和 b 之间的 alpha。
答案应该也适用于fill_between。
重现问题的示例:
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(2022)
x1 = np.random.normal(0, 0.8, 1000)
x2 = np.random.normal(-2, 1, 1000)
x3 = np.random.normal(3, 2, 1000)
kwargs = dict(histtype='stepfilled', alpha=.3, density=True, bins=40)
fig, ax = plt.subplots(figsize=(9, 6))
ax.hist(x1, **kwargs)
ax.hist(x2, **kwargs)
ax.hist(x3, **kwargs)
ax.set_axisbelow(True)
ax.yaxis.grid(color='gray', linestyle='dashed')
ax.xaxis.grid(color='gray', linestyle='dashed')
Run Code Online (Sandbox Code Playgroud)
我有以下数据:
> Data
Date Start End
1 2011-11-15 12:01:27 12:30:15
2 2011-11-16 12:01:25 12:32:15
3 2011-11-17 12:01:02 12:39:12
4 2011-11-19 12:01:12 12:30:18
Run Code Online (Sandbox Code Playgroud)
我还附加了一个持续时间列
Data[,4] <- as.numeric(difftime(Data$End,Data$Start))
names(Data)[4] <- "Duration"
Run Code Online (Sandbox Code Playgroud)
我脑子里有一个Start,End的可视化,看起来有点像股票烛台或OHLC图表,其中x值是Date,y是End - Start.
End位于顶部,矩形下降到Start ---矩形的高度随持续时间的变化而变化.也就是说,每个日期都有一个不同的矩形高度,由开始和结束之间的差异决定.
这里的x轴从2011-11-15到2011-11-19.y轴从12:00:00到12:40:00.
任何ggplot向导都能看到一个简单的方法吗?由于Start和End都随着时间的推移而变化,我是否必须使用geom_ribbon或geom_polygon而不是geom_bar或geom_area?
如果持续时间的值大于2个标准差,那么条形图的颜色会变为红色,这将是非常酷的!
我目前正在(开始)我的大数据和数据可视化项目.所以请告诉我是否有最好的软件来处理大数据和数据可视化,即用于数据分析.
我想为一个条形图着色如下:
我尝试了以下方法:
boxplot(a,col=rep(c("blue","orange","green","pink","grey"),each=5))
Run Code Online (Sandbox Code Playgroud)
这里"a"代表一个affybatch对象.
当然上面的代码每五个条形颜色,我真正需要的是前六个蓝色和接下来的五个橙色等等.
或者甚至将前十个用蓝色着色,接下来三个用橙色着色,剩下的再用蓝色着色也有帮助.我没有使用ggplot,因为这是一个affybatch对象.
这是我在R中的数据框,
New York 8755
Texas 7654
California 6726
Florida 6322
Run Code Online (Sandbox Code Playgroud)
我只希望图形比较并排堆积的条形中的数字,但我还无法实现。我收到错误消息“高度必须是矩阵的向量”。请提出建议!非常感谢!
matplotlib ×4
python ×4
r ×4
seaborn ×3
ggplot2 ×2
bar-chart ×1
bigdata ×1
echarts ×1
histogram ×1
javascript ×1
plotly ×1
subplot ×1
time-series ×1