关于在显示图表时使用的小部件/图形用户界面的建议(不是Jupyter)。

huangapple go评论65阅读模式
英文:

Advice on widget/GUI for displaying charts (not Jupyter)

问题

抱歉,我理解你只需要代码的翻译部分。以下是代码的翻译部分:

I apologise if this question is too opinion based. If that's the case I'll delete it.
对不起,如果这个问题太基于观点,我会删除它。

I'm looking for advice on creating a rather simple widget/GUI for displaying charts with time series data. My idea is to have the user input a date which is used to query the database. The query will return about 20k rows that I'm hoping can be stored in a dataframe in memory to avoid querying the database again.
我正在寻求有关创建一个相当简单的小部件/图形用户界面(GUI)以显示时间序列数据图表的建议。我的想法是让用户输入一个日期,用于查询数据库。查询将返回大约20,000行数据,我希望可以将其存储在内存中的数据框中,以避免再次查询数据库。

For the layout I would like to have a grid of 2x3 charts where the user can select three items per chart to uniquely identify the product and select if it should be a line or scatter plot. There are no requirements for the style of layout around the charts, this is mainly about showing the charts, not a beauty contest.
对于布局,我希望有一个2x3图表的网格,用户可以为每个图表选择三个项目以唯一标识产品,并选择是折线图还是散点图。对于图表周围的样式布局没有特殊要求,主要是显示图表,而不是美观比赛。

For each product there are eight different time series that I would like in a dropdown, the user can choose 1-3. If its a line chart, time will be on the first axis and if its a scatter the user chooses a pair of time series. The input data should be dropdown with the possible values based on the dataframe. For now, its not needed that the user can change the layout of the charts.
对于每个产品,有八个不同的时间序列,我希望它们以下拉菜单的形式出现,用户可以选择1-3个时间序列。如果是折线图,时间将显示在第一个坐标轴上,如果是散点图,用户将选择一对时间序列。输入数据应该是下拉菜单,其可选值基于数据框。暂时不需要用户能够更改图表的布局。

I have looked into ipywidget but its impossible for me to have the users use Jupyter. ipywidget should be available in pycharm pro, but not all users will have the pro version and even having some of them open pycharm is a real stretch. I think the ipywidget would be a good solution, if I was able to roll it out to everyone.
我已经研究了ipywidget,但让用户使用Jupyter对我来说是不可能的。ipywidget应该在pycharm pro中可用,但不是所有用户都会有专业版,甚至让其中一些用户打开pycharm都是一项真正的挑战。我认为ipywidget是一个很好的解决方案,如果我能够将其推广给所有人。

I have also looked in to PyQtGraph but I don't want to massage the data into numpy arrays. Then there's Tkinter and embedding matplotlib charts but I don't want to spend a week on configuring the placement of buttons.
我还研究了PyQtGraph,但我不想将数据转换为NumPy数组。然后有Tkinter和嵌入matplotlib图表,但我不想花一周的时间配置按钮的位置。

So I'm a little lost on what could be a viable solution. The GUI itself should be simple and just be able to show these six charts, based on user input. Ideally it would work with matplotlib, seaborn and plotly, in case I want to change something in the future.
因此,我有点不知道可行的解决方案是什么。GUI本身应该简单,只需根据用户输入显示这六个图表。理想情况下,它应该能够与matplotlib、seaborn和plotly一起使用,以防以后需要进行一些更改。

Please let me know if you have a solution for how this can be done. Is it something like Flask or dash that can do this?
如果您有关于如何实现这一目标的解决方案,请告诉我。是否有类似Flask或dash的东西可以实现这一目标?

英文:

I apologise if this question is too opinion based. If that's the case I'll delete it.

I'm looking for advice on creating a rather simple widget/GUI for displaying charts with time series data. My idea is to have the user input a date which is used to query the database. The query will return about 20k rows that I'm hoping can be stored in a dataframe in memory to avoid querying the database again.

For the layout I would like to have a grid of 2x3 charts where the user can select three items per chart to uniquely identify the product and select if it should be a line or scatter plot. There are no requirements for the style of layout around the charts, this is mainly about showing the charts, not a beauty contest.
For each product there are eight different time series that I would like in a dropdown, the user can choose 1-3. If its a line chart, time will be on the first axis and if its a scatter the user chooses a pair of time series. The input data should be dropdown with the possible values based on the dataframe. For now, its not needed that the user can change the layout of the charts.

I have looked into ipywidget but its impossible for me to have the users use Jupyter. ipywidget should be available in pycharm pro, but not all users will have the pro version and even having some of them open pycharm is a real stretch. I think the ipywidget would be a good solution, if I was able to roll it out to everyone.
I have also looked in to PyQtGraph but I don't want to massage the data into numpy arrays. Then there's Tkinter and embedding matplotlib charts but I don't want to spend a week on configuring the placement of buttons.

So I'm a little lost on what could be a viable solution. The GUI itself should be simple and just be able to show these six charts, based on user input. Ideally it would work with matplotlib, seaborn and plotly, in case I want to change something in the future.

Please let me know if you have a solution for how this can be done. Is it something like Flask or dash that can do this?

答案1

得分: 0

I tried Corralien's solution with streamlit. I've used used plotly to create the charts. As a starting point, this is what I'll be using. plotly creates a chart grid that streamlit can show directly. I guess the code itself is self-explanatory.

import plotly.graph_objects as go
from plotly.subplots import make_subplots
import streamlit as st

fig = make_subplots(rows=2, cols=3)

fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='lines'), row=1, col=1)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='lines'), row=1, col=2)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='lines'), row=1, col=3)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='markers'), row=2, col=1)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='markers'), row=2, col=2)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='markers'), row=2, col=3)

st.plotly_chart(fig)

This outputs the chart grid as is and does what I asked for. To begin with, I'll hard code how the charts look and only have the user select which product to look at. Later I'll add more user input to change the charts and combine different products.

英文:

I tried Corralien's solution with streamlit. I've used used plotly to create the charts. As a starting point, this is what I'll be using. plotly creates a chart grid that streamlit can show directly. I guess the code itself is self explanatory.

import plotly.graph_objects as go
from plotly.subplots import make_subplots
import streamlit as st

fig = make_subplots(rows=2, cols=3)

fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='lines'), row=1, col=1)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='lines'), row=1, col=2)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='lines'), row=1, col=3)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='markers'), row=2, col=1)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='markers'), row=2, col=2)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='markers'), row=2, col=3)

st.plotly_chart(fig)

This outputs the chart grid as is and does what I asked for. To begin with, I'll hard code how the charts look and only have the user select which product to look at. Later I'll add more user input to change the charts and combine different products.

huangapple
  • 本文由 发表于 2023年2月19日 06:24:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/75496762.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定