Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Pie chart labels out of Figure, even with tight_layout #4251

Closed as not planned
Labels
New featurekeepItems to be ignored by the “Stale” Github Actiontopic: geometry managerLayoutEngine, Constrained layout, Tight layouttopic: text
@lafrech

Description

@lafrech

Hi.

I'm drawing a pie chart and the labels are cut off of the Figure. I thought this would be solved by tight_layout (as perthis issue for instance) but this does not seem to be the case, at least for a pie chart.

Below is a code snippet to reproduce. In fact, tight_layout makes it even worse since it ignores the labels and crops tighter to the pie.

Is there a way around this ?

Am I doing things wrong ?

# -*- coding: utf-8 -*-importsysfromPyQt4importQtGuifrommatplotlib.figureimportFigurefrommatplotlib.backends.backend_qt4aggimport (FigureCanvasQTAggasFigureCanvas)classMplCanvas(FigureCanvas):"""Class to represent the FigureCanvas widget"""def__init__(self):# Setup Matplotlib Figure and Axisself.fig=Figure(facecolor="white")self.axes=self.fig.add_subplot(111)# Initialization of the canvassuper(MplCanvas,self).__init__(self.fig)# Define the widget as expandableFigureCanvas.setSizePolicy(self,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)# Notify the system of updated policyFigureCanvas.updateGeometry(self)# Call tight_layout on resize#self.mpl_connect('resize_event', self.fig.tight_layout)classMplWidget(QtGui.QWidget):"""Widget defined in Qt Designer"""def__init__(self,parent=None):super(MplWidget,self).__init__(parent)# Set canvas and navigation toolbarself.canvas=MplCanvas()# Layout as vertical boxself.vbl=QtGui.QVBoxLayout()self.vbl.addWidget(self.canvas)self.setLayout(self.vbl)if__name__=="__main__":app=QtGui.QApplication(sys.argv)W=MplWidget()W.canvas.axes.cla()values= [0.2,0.5,0.3]labels= ['label','looooooog label','very loooooooooooooooooooooooog label'             ]W.canvas.axes.pie(values,labels=labels)W.canvas.axes.axis('equal')W.canvas.fig.tight_layout()W.canvas.draw()W.show()sys.exit(app.exec_())

I'm using python 2.7 and Matplotlib 1.4.3~rc1 from Debian experimental.

Metadata

Metadata

Assignees

No one assigned

    Labels

    New featurekeepItems to be ignored by the “Stale” Github Actiontopic: geometry managerLayoutEngine, Constrained layout, Tight layouttopic: text

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp