Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with plotting multiple plots in the same MatplotlibWidget graph

Problem with plotting multiple plots in the same MatplotlibWidget graph

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt4matplotlibgraph
5 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NilleDaWize
    wrote on 21 Aug 2019, 09:09 last edited by NilleDaWize
    #1

    Hi,

    I am new to both python and QT4 but have since a couple of weeks back been working on a software that will take user based input and present the results in the QT matplotlibwidget. I can currently present one plot at a time in the widget but have not been able to plot multiple plots in the same graph.
    Oddly enough I am able to achieve multiple plots in the same graph if I use a normal matplotlib window(not the widget) when I run the same code using plt.show() instead of draw(). However when I call self.matplotlibwidget.axes.show() on the matplotlibwidget nothing appears in the plot.

    Here is the code that I can't get to run the way I would like:

    def plotRetained(self):
        i = 0
        colors = cm.rainbow(np.linspace(0, 1, len(Model.busSetDictionary)))
        for everySet in Model.busSetDictionary:
        #busSetDictionary is a dictionary containing dictionaries(busDictionary) which contains a list
            busDictionary = Model.busSetDictionary[i]
            data = {"x":[], "y":[], "label":[]}
            for label, coord in busDictionary.items():
                data["x"].append(coord[1])
                data["y"].append(coord[2])
        
            self.matplotlibwidget.axes.plot(data["x"], data["y"], marker='o', color = colors[i], markerfacecolor=colors[i], markersize=12)
            i+=1  
    self.matplotlibwidget.draw()
    

    When I run this code only the last itteration of busDictionary will be plotted instead of all the busDictionaries.

    If anybody could help me identify the problem that would be greatly appreciated!

    Ps. There are 1500 lines of code so I can not post all of it but if anyone is curious about other parts of the code just let me know and I will post that too.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 21 Aug 2019, 20:45 last edited by
      #2

      Hi and welcome to devnet,

      This is a question you should rather bring to the Matplotlib folks.

      On a side note, unless you are locked to that version, please move to Qt 5. Qt 4 has reached end of life a few years ago.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        NilleDaWize
        wrote on 22 Aug 2019, 07:03 last edited by
        #3

        The reason I asked you guys is that is seems specific to the QT MatplotlibWidget. Like I mentioned in the post I can achieve what I want in the normal Matplotlib Window but not in the MatplotlibWidget

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 22 Aug 2019, 07:16 last edited by
          #4

          Well, that's the thing: the Qt MatplotLibWidget is still implemented by these guys hence my suggestion to ask them.

          You should also check whether you are using PyQt or PySide to see if it makes any difference. It should not but who knows.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • N Offline
            N Offline
            NilleDaWize
            wrote on 22 Aug 2019, 07:24 last edited by
            #5

            Ahh I see. I'll check it out!

            Thanks for the suggestion. If you have any other ideas please let me know.

            1 Reply Last reply
            0

            5/5

            22 Aug 2019, 07:24

            • Login

            • Login or register to search.
            5 out of 5
            • First post
              5/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved