fviz我正在 R 中运行 PCA 并使用包中的函数 绘制结果Factoextra。我想使用此代码更改标题和值等图例属性
acp<-PCA(params_alpha, scale.unit = TRUE, ncp=5, quali.sup=c(1,2))\n\n plot1<-fviz_pca_biplot(acp, geom=c("point"), pointsize=1, col.var="black", axes=c(1,2), habillage=2)+\n theme(legend.text = element_text("Lobulo"))\nRun Code Online (Sandbox Code Playgroud)\n\n我这里有两个主要问题:首先,当我运行代码时出现此错误:
\n\n In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font family not found in Windows font database \nRun Code Online (Sandbox Code Playgroud)\n\n我尝试使用这篇文章Can't Change fonts in ggplot/geom_text来解决它,但它没有效果。这段代码的另一个问题是图例属性根本没有改变。
我只想更改图例标题和值,但我不知道如何更改。如果您能帮助我,我\xc2\xb4d将非常感激。
\n我正在尝试为包含超过 5000 个唯一值的字段创建过滤器。但是,过滤器的查询会自动设置 1000 行的限制,这意味着大多数值不会显示在过滤器下拉列表中。
DEFAULT_SQLLAB_LIMIT我通过将和增加到 6000来更新“anaconda3/lib/python3.7/site-packages”目录中的 config.py 文件QUERY_SEARCH_LIMIT,但这不起作用。
还有其他配置需要更新吗?
PS - 下面的代码片段显示了问题似乎来自的过滤器的 json 表示形式。
"query": "SELECT casenumber AS casenumber\nFROM pa_permits_2019\nGROUP BY casenumber\nORDER BY COUNT(*) DESC\nLIMIT 1000\nOFFSET 0"
Run Code Online (Sandbox Code Playgroud) 如下图所示,我正在寻找一种简单的方法将两个或多个热图合并为一个,即具有多个颜色图的热图。
这个想法是将每个单元格分解为多个子单元格。我找不到任何已经实现了这样的可视化功能的Python库。有人知道(至少)与此相关的事情吗?
时间序列数据是随时间变化的数据。我正在尝试用 python 制作时间序列数据线图的动画。在我下面的代码中,这转化为绘制xtraj它们和trangex 。但情节似乎并不奏效。
我在堆栈溢出上发现了类似的问题,但这里提供的解决方案似乎都不起作用。一些类似的问题是matplotlibAnimatedlineplotstaysempty、MatplotlibFuncAnimationnotanimatinglineplot以及引用帮助文件AnimationswithMatplotlib 的教程。
我首先使用第一部分创建数据并使用第二部分对其进行模拟。我尝试重命名将用作 y 值和 x 值的数据,以便更容易阅读。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
dt = 0.01
tfinal = 5.0
x0 = 0
sqrtdt = np.sqrt(dt)
n = int(tfinal/dt)
xtraj = np.zeros(n+1, float)
trange = np.linspace(start=0,stop=tfinal ,num=n+1)
xtraj[0] = x0
for i in range(n):
xtraj[i+1] = xtraj[i] + np.random.normal()
x = trange
y = xtraj
# animation line plot example
fig = …Run Code Online (Sandbox Code Playgroud) 下面的代码适用于我的 CNN 模型,我想绘制它的准确性和损失,任何帮助将不胜感激。我希望使用 matplotlib 绘制输出,因此需要任何建议,因为我不确定如何解决这个问题。两张图显示了训练和验证的准确性,另一张图显示了训练和验证的损失。
bin_labels = {1:'EOSINOPHIL',2:'LYMPHOCYTE',3:'MONOCYTE',4:'NEUTROPHIL'}
def CNN(imgs,img_labels,test_imgs,test_labels,stride):
#Number of classes (2)
num_classes = len(img_labels[0])
#Size of image
img_rows,img_cols=imgs.shape[1],imgs.shape[2]
input_shape = (img_rows, img_cols, 3)
#Creating the model
model = Sequential()
#First convolution layer
model.add(Conv2D(32, kernel_size=(3, 3),
activation='relu',
input_shape=input_shape,
strides=stride))
#First maxpooling layer
model.add(MaxPooling2D(pool_size=(2, 2)))
#Second convolution layer
model.add(Conv2D(64, (3, 3), activation='relu'))
#Second maxpooling layer
model.add(MaxPooling2D(pool_size=(2, 2)))
#Third convolution layer
model.add(Conv2D(128, (3, 3), activation='relu'))
#Third maxpooling layer
model.add(MaxPooling2D(pool_size=(2, 2)))
#Convert the matrix to a fully connected layer
model.add(Flatten())
#Dense …Run Code Online (Sandbox Code Playgroud) 我有一个带有颜色条和图例的图。我想将图例放置在绘图之外的颜色栏右侧。为了实现此目的,我使用 bbox_to_anchor 参数,但这会导致图例被截断:
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
_, ax = plt.subplots()
extent = np.r_[0, 1, 0, 1]
space = np.linspace(0, 1)
probs = np.array([[norm.cdf(x + y) for x in space] for y in space])
colormap = ax.imshow(probs, aspect="auto", origin="lower", extent=extent, alpha=0.5)
colorbar = plt.colorbar(colormap, ax=ax)
colorbar.set_label(f"Probability")
ax.scatter(
[0.2, 0.4, 0.6], [0.8, 0.6, 0.4], color="r", label="Labeled Points",
)
plt.legend(loc="center left", bbox_to_anchor=(1.3, 0.5))
plt.title
plt.show()
Run Code Online (Sandbox Code Playgroud)

为了修复图例,我在 plt.show() 之前插入对 plt.tight_layout() 的调用,但这会导致纵横比扭曲:

如何显示整个图例并保留轴的纵横比?
python visualization data-visualization matplotlib aspect-ratio
我正在努力隐藏线图中某些但不是所有线的图例。这是现在的情节。
本质上,我想隐藏浅灰色线条的图例,同时将彩色线条保留在适当的位置。
这是我的代码:
import plotly.graph_objects as go
fig = go.Figure()
fig.update_layout(autosize=False, width=800, height=500, template='none')
fig.update_layout(title = 'Title', xaxis_title = 'Games', yaxis_title = 'Profit')
for team in rest_teams:
fig.add_traces(go.Scatter(x=df['x'], y = df[team], name = team, line = {'color': '#F5F5F5'}))
for team in big_eight:
line_dict = {'color': cmap[team]}
fig.add_traces(go.Scatter(x=df['x'], y = df[team], name = team, line = line_dict))
fig.show()
Run Code Online (Sandbox Code Playgroud)
我可以更新布局
fig.update_layout(showlegend=False)
Run Code Online (Sandbox Code Playgroud)
这隐藏了整个事情并且不是最佳的。如有帮助,将不胜感激。
在 中d3,我们可以更改选择中元素的顺序,例如使用raise。
然而,当我们重新绑定数据并使用 时join,该顺序将被丢弃。
enter当我们使用绑定数据的“旧方法”(使用和 )时,这种情况不会发生merge。
请参阅下面的小提琴,您可以在其中单击一个圆圈(例如蓝色圆圈)将其置于前面。当您单击“重绘”时,使用 时,圆会恢复到原来的 z 顺序join,但使用enter和时则不会merge。
我可以实现圆圈保持其 z 顺序并仍然使用吗join?
const data = [{
id: 1,
v: 10,
c: 'red'
}, {
id: 2,
v: 30,
c: 'blue'
}, {
id: 3,
v: 60,
c: 'green'
}]
let nDrawCall = 0
function redraw() {
nDrawCall++
//svg1 with old enter-merge pattern that works
const circles = d3.select('#svg1')
.selectAll('circle')
.data(data, …Run Code Online (Sandbox Code Playgroud)javascript visualization data-visualization d3.js typescript
我正在尝试找到构建音乐可视化工具的最佳方法,以便在网络浏览器中运行.Unity是一个选项,但我需要构建一个自定义音频导入/分析插件来获得最终用户的声音输出.Quartz做我需要的但只能在Mac/Safari上运行.WebGL似乎没有准备好.Raphael主要是2D,但仍然存在获取用户声音的问题......任何想法?有没有人这样做过?
visualization quartz-graphics raphael unity-game-engine webgl
visualization ×10
python ×5
matplotlib ×3
animation ×1
aspect-ratio ×1
c++ ×1
d3.js ×1
ggplot2 ×1
graph ×1
javascript ×1
linegraph ×1
numpy ×1
pca ×1
plot ×1
plotly ×1
r ×1
raphael ×1
real-time ×1
seaborn ×1
typescript ×1
validation ×1
webgl ×1