我有一个LDA模型,包含10K文档中最常见的10个主题.现在,它只是每个主题具有相应概率分布的单词的概述.
我想知道是否有可用于python可视化这些主题的东西?
我正在尝试使用 ggrepel 为我正在使用 R 和 ggplot2 处理的图表创建文本标签。我发现它对于排斥单个点非常有用,但我经常遇到它与其他一些绘图对象重叠的问题。

我试图将它添加到情节中,如下所示:
plot + ggrepel::geom_text_repel(aes(y = Ratio, label = Ratio), direction = "y")
Run Code Online (Sandbox Code Playgroud)
有什么方法可以告诉 ggrepel 避免 ggplot 上的所有内容吗?我尝试过搜索并为此想出一些东西,但我被困住了。
我希望我的问题足够清楚,谢谢。
我正在开发一个二维平面有限元工具。其中一项功能是能够可视化特定对象上的应力。
此工具使用以下数据创建四边形网格:
节点:numpy 数组[[x1 y1], [x2 y2], etc]->x和y网格中每个节点的坐标
元素:numpy 数组[[1 2 3 4], [2 3 5 6]]->数组的每一行对应于网格的一个特定元素的 4 个点。
我能够实现一种绘制网格的方法:
import matplotlib.pyplot as plt
import matplotlib.collections
import matplotlib.cm as cm
import numpy as np
def showMeshPlot(nodes, elements):
y = nodes[:,0]
z = nodes[:,1]
#/sf/ask/3474821801/
def quatplot(y,z, quatrangles, ax=None, **kwargs):
if not ax: ax=plt.gca()
yz = np.c_[y,z]
verts= yz[quatrangles]
pc = matplotlib.collections.PolyCollection(verts, **kwargs)
ax.add_collection(pc)
ax.autoscale()
plt.figure()
plt.gca().set_aspect('equal')
quatplot(y,z, np.asarray(elements), ax=None, color="crimson", …Run Code Online (Sandbox Code Playgroud) 我正在从事数据可视化任务,其中使用了 plotly(python) 中的 Dash。当我运行代码时,我收到一个错误 -
导入错误:无法导入名称“事件”
我尝试了各种安装过程,如 pip install events 或 pip install Event ,但我无法得到我的错误解决方案。
代码:
import dash
from dash.dependencies import Output, Event
import dash_core_components as dcc
import dash_html_components as html
import plotly
import random
import plotly.graph_objs as go
from collections import deque
x = deque(maxlen=20)
y = deque(maxlen=20)
x.append(1)
y.append(1)
app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.Graph(id = 'live-graph', animate = True),
dcc.Interval(
id = 'graph-update',
interval = 1000
)
]
)
@app.callback(Output('live-graph','figure'),
events = [Event('graph-update','interval')])
def update_graph(): …Run Code Online (Sandbox Code Playgroud) 我找不到在绘图语法中指定这一点的简单方法,因此我尝试使用 Pandas 修改数据框。这也没有奏效。
我的代码如下:
import plotly.plotly as py
import plotly.graph_objs as go
import pandas as pd
df = pd.read_csv('C:/Users/Documents/Python/CKANMay.csv')
sd = df.nlargest(3,'Views')
fd = sd.sort_values(by='Views', ascending = False)
my_data = [go.Bar( x = fd.Views, y = fd.Publisher, orientation = 'h')]
my_layout = ({"title": "Most popular publishers",
"yaxis": {"title":"Publisher"},
"xaxis": {"title":"Views"},
"showlegend": False})
fig = go.Figure(data = my_data, layout = my_layout)
py.iplot(fig)
Run Code Online (Sandbox Code Playgroud)
我想反转条形图,以便具有最大值的列位于顶部。感谢您的任何帮助。
我正在 R Studio 中使用gt包创建一个表,但我无法找到一种优雅的方法来使具有多行的表的列更具可读性。
采取以下代码:
gt::sp500 %>% slice(1:100) %>%
mutate(month = lubridate::month(date)) %>%
group_by(month) %>%
gt::gt(rowname_col = "date")
Run Code Online (Sandbox Code Playgroud)
但一旦超出这个范围,我发现自己必须向上滚动才能记住哪一列较高,哪一列较低,以及调整后的收盘价是在第六列还是第四列。有没有办法在滚动时将这些列冻结在适当的位置(使用 gt 包),或者在每个组之后轻松重复列标题(不会弄乱底层数据)?
有没有办法在 3-D 等距视图中制作一个 z-stack 2-D 图像,每个 2-D 图像中的点向下投影到下一个 2-D 图像切片?我确信这有一个技术术语,但我只是没有词汇来找到最相关的答案。有人能指出我正确的方向吗?
下面,我已经绘制了一个关于它是什么样子的“想法”。我很想知道这是否可行,而无需为matplotlib其他 Python 绘图库重新发明轮子。
可以通过在 x、y 和 z 轴顶部叠加箭头来将图形的箭头更改为箭头,以创建轴是箭头的错觉,或者直接将框架的设置更改为Matplot lib 框架,以便在 3D 绘图上获得相同的结果,用箭头显示 (x,y,z)?
转动这个
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# generate sample points and straight line
z = np.repeat(0, 100)
x = np.repeat(1.0, 100)
y = np.linspace(start=3.0, stop=6.0, num=100)
ax.plot(x, y, z, c='red') # draw straight line
ax.view_init(45, -150) # angle to show
# set axes limits and labels
ax.set_xlabel(r"$x$"); ax.set_ylabel(r"$y$"); ax.set_zlabel(r"$z$")
ax.set_xlim(0,1.1) ;ax.set_ylim(6,3) ;ax.set_zlim(0,1.75)
# Remove tick marks
ax.set_xticks([0,0.25,0.5,0.75,1]) ; ax.set_xticklabels(['0','1','2','4','T'])
ax.set_yticks([6.0,5.5,5,4.5,4.0,3.5,3]) ; ax.set_yticklabels(["","","","","","",""])
ax.set_zticks([1.75,1.25,0.75,0.25]) ax.set_zticklabels(['','','',''])
# change …Run Code Online (Sandbox Code Playgroud) 使用 R 中的“plotly”库 - 我生成了一些随机数据并进行了一些交互式数据可视化:
library(plotly)
library(ggplot2)
library(dplyr)
library(hrbrthemes)
#subplot 1
data1 <- data.frame(
day = as.Date("2017-06-14") - 0:364,
value = runif(365) - seq(-140, 224)^2 / 10000
)
p1 <- ggplot(data1, aes(x=day, y=value)) +
geom_line( color="#69b3a2") +
xlab("") +
theme_ipsum() +
theme(axis.text.x=element_text(angle=60, hjust=1))
fig1 <- ggplotly(p1)
scatter_1 = data.frame(x = rnorm(100,100,100), y = rnorm(100,100,100))
fig2 <- plot_ly(data = scatter_1, x = ~x, y = ~y)
#subplot 2
data2 <- data.frame(
day = as.Date("2017-06-14") - 0:364,
value = runif(365) - seq(-140, …Run Code Online (Sandbox Code Playgroud) python ×5
plotly ×4
matplotlib ×3
r ×3
c# ×1
ggplot2 ×1
ggrepel ×1
gt ×1
html ×1
interactive ×1
lda ×1
mesh ×1
pandas ×1
plot ×1
plotly-dash ×1
python-3.x ×1
seaborn ×1
sorting ×1
treemap ×1
winforms ×1