0

I can not get the plot stretched to the whole area of the figure. When I call the tight_layout, the required height of the plot is obtained, but I can not achieve the required length: enter image description here

enter image description here

Code:

self.figure = plt.figure()
    self.canvas = FigureCanvas(self.figure)
    # self.figure.set_figheight(15)
    # self.figure.set_figwidth(5)
    #self.figure.tight_layout()
    self.figure.set_size_inches(1, 7)
    self.graphBox.addWidget(self.canvas)

    # ------------------------------------------------------------------
    # ------------------------------------------------------------------
    t = np.arange(0.0, 2.0, 0.01)
    s = np.sin(2 * np.pi * t)
    ax = plt.subplot2grid((1, 1), (0, 0))
    ax.set_facecolor(color='#b3ff66')
    ax.plot(t, s)
    self.canvas.draw()
    #plt.tight_layout(h_pad=1.0, w_pad=1.0)
    # ------------------------------------------------------------------
    # ------------------------------------------------------------------
  • The code from the question does not allow to identify what *exactly* you are doing. However, if you set the figure size to be 1 inch wide and 7 inch heigh, it's clear that the axes inside of it will show a similar aspect ratio on screen. Using `.set_size_inches(12, 7)` will probably look much nicer. So for further help you need to explain much more in detail what you are trying to achieve. – ImportanceOfBeingErnest Mar 20 '18 at 11:41
  • The function that you suggested solved my problem. Initially, I did not pay attention to parameters 1 and 7. Thank you. – alex.stepan Mar 20 '18 at 12:36

0 Answers0