Here is my sample code.I want to reduce the size of the height,in my example i mention figure size also but i didn't get any changes please help me.Thank you in advance.
Given bellow is my sample code:
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT
from pyface.qt import QtGui, QtCore
import sys
class MplCanvas1(FigureCanvas):
def __init__(self, parent = None, width = 1, height = 0.5):
self.figure = Figure(figsize = (width, height))
self.axes = self.figure.add_subplot(111)
FigureCanvas.__init__(self, self.figure)
self.setParent(parent)
FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
t = np.linspace(0, 100)
s= np.sin(t)
self.sinPlot= self.axes.plot(t,s, color="#0095a2")
self.ax2 = self.axes.twinx()
self.ax2.bar(10,1, align = "edge", width = 20,alpha= 0.5, color ='orange')
self.axes.spines['right'].set_visible(False)
self.axes.spines['top'].set_visible(False)
self.ax2.spines['right'].set_visible(False)
self.ax2.spines['top'].set_visible(False)
self.ax2.spines['left'].set_visible(False)
self.ax2.spines['bottom'].set_visible(False)
self.ax2.axis('off')
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
self.vbox = QtGui.QVBoxLayout()
self.canvas = MplCanvas1()
self.vbox.addWidget(self.canvas)
self.setLayout(self.vbox)
qApp = QtGui.QApplication(sys.argv)
aw = Example()
aw.show()
sys.exit(qApp.exec_())
Comments
Post a Comment