0

Im trying to limit my bar chart at 100 and i tried putting ylim(100) but it wont show and it wont work

import matplotlib
matplotlib.use('module://kivy.garden.matplotlib.backend_kivy')
from matplotlib.figure import Figure
from numpy import arange, sin, pi
from kivy.app import App

import numpy as np
from kivy.garden.matplotlib.backend_kivyagg import FigureCanvas,\
NavigationToolbar2Kivy
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
from matplotlib.transforms import Bbox
from kivy.uix.button import Button
from kivy.graphics import Color, Line, Rectangle

import matplotlib.pyplot as plt

N = 5
menMeans = (20, 35, 30, 35, 27)
menStd = (2, 3, 4, 1, 2)

ind = np.arange(N)  # the x locations for the groups
width = 0.35       # the width of the bars

plt.ylim(100)


fig, ax = plt.ylim(1000)
fig, ax = plt.subplots()
rects1 = ax.bar(ind, menMeans, width, color='b', yerr=menStd)

womenMeans = (25, 32, 34, 20, 25)
womenStd = (3, 5, 2, 3, 3)
rects2 = ax.bar(ind + width, womenMeans, width, color='r', yerr=womenStd)

# add some text for labels, title and axes ticks
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind + width)
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))
ax.legend((rects1[0], rects2[0]), ('Men', 'Women'))

canvas = fig.canvas


class MatplotlibTest(App):
    title = 'Matplotlib Test'

    def build(self):
        fl = BoxLayout(orientation="vertical")
        nav1 = NavigationToolbar2Kivy(canvas)
        fl.add_widget(nav1.actionbar)
        fl.add_widget(canvas)
        return fl

        if __name__ == '__main__':
            MatplotlibTest().run()

As you can see in the code i tried putting ylim but its not showing.

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
xx4xx4
  • 45
  • 7
  • `plt.ylim` expects *two* arguments or a tuple. What is 100? The upper or lower limit? – ImportanceOfBeingErnest Jan 29 '18 at 17:39
  • You're only setting the bottom limit, not the top. By specifying only a single argument into `ylim`, it modifies the bottom limit but not the top. – rayryeng Jan 29 '18 at 17:40
  • As well as only supplying the lower limit, you also set the `ylim` before you create the figure, so that line will have no effect on the figure you display later. Move `plt.ylim` to after `fig, ax = plt.subplots()` – tmdavison Jan 29 '18 at 17:55
  • thanks.. here's another question its in my repo the code btw.. https://github.com/jasjamjos/Sentiment-Analysis i tried putting a bar chart in my popups but its not working – xx4xx4 Jan 29 '18 at 19:08
  • Make another question and post it. – rayryeng Jan 29 '18 at 21:27

0 Answers0