The plt.* Settings are usually applied to the current matplotlib plot; with plt.subplot , you start a new story, so the settings no longer apply to it. You can share shortcuts, ticks, etc., Axes objects related to charts ( see examples here ), but IMHO this would be superfluous here. Instead, I would suggest putting the general "style" in one function and invoking it for the plot:
def applyPlotStyle(): plt.xlabel('Size') plt.ylabel('Time(s)'); plt.title('Matrix multiplication') plt.xticks(range(100), rotation=30, size='small') plt.grid(True) plt.subplot(211) applyPlotStyle() plt.plot(xl, serial_full, 'r--') plt.plot(xl, acc, 'bs') plt.plot(xl, cublas, 'g^') plt.subplot(212) applyPlotStyle() plt.yscale('log') plt.plot(xl, serial_full, 'r--') plt.plot(xl, acc, 'bs') plt.plot(xl, cublas, 'g^')
On the side of the note, you can snatch more duplication by extracting your build commands into a function like this:
def applyPlotStyle(): plt.xlabel('Size') plt.ylabel('Time(s)'); plt.title('Matrix multiplication') plt.xticks(range(100), rotation=30, size='small') plt.grid(True) def plotSeries(): applyPlotStyle() plt.plot(xl, serial_full, 'r--') plt.plot(xl, acc, 'bs') plt.plot(xl, cublas, 'g^') plt.subplot(211) plotSeries() plt.subplot(212) plt.yscale('log') plotSeries()
On the other hand, it may be sufficient to put a title at the top of the picture (instead of each chart), for example, using suptitle . Similary, it may be enough for xlabel appear only under the second graph:
def applyPlotStyle(): plt.ylabel('Time(s)'); plt.xticks(range(100), rotation=30, size='small') plt.grid(True) def plotSeries(): applyPlotStyle() plt.plot(xl, serial_full, 'r--') plt.plot(xl, acc, 'bs') plt.plot(xl, cublas, 'g^') plt.suptitle('Matrix multiplication') plt.subplot(211) plotSeries() plt.subplot(212) plt.yscale('log') plt.xlabel('Size') plotSeries() plt.show()