1. <tfoot id='UNA98'></tfoot>

        <small id='UNA98'></small><noframes id='UNA98'>

          <bdo id='UNA98'></bdo><ul id='UNA98'></ul>
        <i id='UNA98'><tr id='UNA98'><dt id='UNA98'><q id='UNA98'><span id='UNA98'><b id='UNA98'><form id='UNA98'><ins id='UNA98'></ins><ul id='UNA98'></ul><sub id='UNA98'></sub></form><legend id='UNA98'></legend><bdo id='UNA98'><pre id='UNA98'><center id='UNA98'></center></pre></bdo></b><th id='UNA98'></th></span></q></dt></tr></i><div id='UNA98'><tfoot id='UNA98'></tfoot><dl id='UNA98'><fieldset id='UNA98'></fieldset></dl></div>
      1. <legend id='UNA98'><style id='UNA98'><dir id='UNA98'><q id='UNA98'></q></dir></style></legend>
      2. 如何将绘图作为 PyQt5 小部件?

        时间:2023-08-05
        <i id='cFvGI'><tr id='cFvGI'><dt id='cFvGI'><q id='cFvGI'><span id='cFvGI'><b id='cFvGI'><form id='cFvGI'><ins id='cFvGI'></ins><ul id='cFvGI'></ul><sub id='cFvGI'></sub></form><legend id='cFvGI'></legend><bdo id='cFvGI'><pre id='cFvGI'><center id='cFvGI'></center></pre></bdo></b><th id='cFvGI'></th></span></q></dt></tr></i><div id='cFvGI'><tfoot id='cFvGI'></tfoot><dl id='cFvGI'><fieldset id='cFvGI'></fieldset></dl></div>
        <tfoot id='cFvGI'></tfoot>
          <tbody id='cFvGI'></tbody>

        <small id='cFvGI'></small><noframes id='cFvGI'>

          • <bdo id='cFvGI'></bdo><ul id='cFvGI'></ul>

                  <legend id='cFvGI'><style id='cFvGI'><dir id='cFvGI'><q id='cFvGI'></q></dir></style></legend>
                  本文介绍了如何将绘图作为 PyQt5 小部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在做 GUI,其中应该有一个带有以下情节的小部件:

                  I am doing GUI where there should be a widget with the following plot:

                  import plotly.express as px
                  df = px.data.tips()
                  fig = px.box(df, x="day", y="total_bill", color="smoker")
                  fig.update_traces(quartilemethod="exclusive") # or "inclusive", or "linear" by default
                  fig.show() 
                  

                  你能提出一些建议吗?

                  推荐答案

                  您可以使用 QtWebEngineWidgets.QWebEngineView 小部件来显示图形.您可能需要先安装 PyQtWebEngine 包.这是一个小例子:

                  You can use a QtWebEngineWidgets.QWebEngineView widget to show the figure. You might need to install the PyQtWebEngine package first. Here is a small example:

                  from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets
                  import plotly.express as px
                  
                  
                  class Widget(QtWidgets.QWidget):
                      def __init__(self, parent=None):
                          super().__init__(parent)
                          self.button = QtWidgets.QPushButton('Plot', self)
                          self.browser = QtWebEngineWidgets.QWebEngineView(self)
                  
                          vlayout = QtWidgets.QVBoxLayout(self)
                          vlayout.addWidget(self.button, alignment=QtCore.Qt.AlignHCenter)
                          vlayout.addWidget(self.browser)
                  
                          self.button.clicked.connect(self.show_graph)
                          self.resize(1000,800)
                  
                      def show_graph(self):
                          df = px.data.tips()
                          fig = px.box(df, x="day", y="total_bill", color="smoker")
                          fig.update_traces(quartilemethod="exclusive") # or "inclusive", or "linear" by default
                          self.browser.setHtml(fig.to_html(include_plotlyjs='cdn'))
                  
                  if __name__ == "__main__":
                      app = QtWidgets.QApplication([])
                      widget = Widget()
                      widget.show()
                      app.exec()
                  

                  这篇关于如何将绘图作为 PyQt5 小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PyQt5“定时器不能从另一个线程启动"更改 Q 下一篇:对 QSlider 使用浮点数

                  相关文章

                  最新文章

                  <small id='SEKZz'></small><noframes id='SEKZz'>

                  <legend id='SEKZz'><style id='SEKZz'><dir id='SEKZz'><q id='SEKZz'></q></dir></style></legend>
                  • <bdo id='SEKZz'></bdo><ul id='SEKZz'></ul>

                    1. <tfoot id='SEKZz'></tfoot>

                      <i id='SEKZz'><tr id='SEKZz'><dt id='SEKZz'><q id='SEKZz'><span id='SEKZz'><b id='SEKZz'><form id='SEKZz'><ins id='SEKZz'></ins><ul id='SEKZz'></ul><sub id='SEKZz'></sub></form><legend id='SEKZz'></legend><bdo id='SEKZz'><pre id='SEKZz'><center id='SEKZz'></center></pre></bdo></b><th id='SEKZz'></th></span></q></dt></tr></i><div id='SEKZz'><tfoot id='SEKZz'></tfoot><dl id='SEKZz'><fieldset id='SEKZz'></fieldset></dl></div>