|
From: Damon M. <dam...@gm...> - 2012-10-02 18:14:35
|
On Tue, Oct 2, 2012 at 6:07 PM, Eric Firing <ef...@ha...> wrote: > On 2012/10/02 4:12 AM, Mic wrote: >> Hi Eric, >> I have a dataset which contains about 4600 values. >> >> Is it possible to display 4600 values with a bar char and labels? >> >> Thank you in advance. > > Mic, > > I don't think so, as a practical matter. A screen doesn't even have > that many pixels of width. > > Eric > >> >> >> >> On Tue, Oct 2, 2012 at 4:04 PM, Eric Firing <ef...@ha... >> <mailto:ef...@ha...>> wrote: >> >> On 2012/10/01 7:28 PM, Mic wrote: >> > Hi, >> > >> > I have got the following error with the following code: >> > /$ python mpl.py/ <http://mpl.py/> >> > /Traceback (most recent call last):/ >> > / File >> > >> "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk.py", >> > line 398, in expose_event/ >> > / self._render_figure(self._pixmap, w, h)/ >> > / File >> > >> "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", >> > line 75, in _render_figure/ >> > / FigureCanvasAgg.draw(self)/ >> > / File >> > >> "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", >> > line 416, in draw/ >> > / self.renderer = self.get_renderer()/ >> > / File >> > >> "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", >> > line 435, in get_renderer/ >> > / self.renderer = RendererAgg(w, h, self.figure.dpi)/ >> > / File >> > >> "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", >> > line 72, in __init__/ >> > / self._renderer = _RendererAgg(int(width), int(height), dpi, >> > debug=False)/ >> > /ValueError: width and height must each be below 32768/ >> > /The program 'mpl.py' received an X Window System error./ >> > /This probably reflects a bug in the program./ >> > /The error was 'BadAlloc (insufficient resources for operation)'./ >> > / (Details: serial 486 error_code 11 request_code 53 minor_code 0)/ >> > / (Note to programmers: normally, X errors are reported >> asynchronously;/ >> > / that is, you will receive the error a while after causing it./ >> > / To debug your program, run it with the --sync command line/ >> > / option to change this behavior. You can then get a meaningful/ >> > / backtrace from your debugger if you break on the gdk_x_error() >> > function.)/ >> > >> > With the following code: >> > /import random / >> > /import matplotlib.pyplot as plt / >> > // >> > /coverages = [random.randint(1,10)*2] * 4605 / >> > /contig_names = ['AAB0008r'] * len(coverages) / >> > /# Set the figure size / >> > /#fig = plt.figure(1, [20, 2]) / >> > /fig = plt.figure(figsize=(int(len(coverages)*0.1), 4)) / >> > // >> > /ax = fig.add_subplot(111) / >> > // >> > /# Set the x-axis limit / >> > /#ax.set_xlim(-1,100) / >> > /ax.set_xlim(0,len(coverages)) / >> > /#ax.set_ylim(0,3) / >> > /ax.yaxis.grid(True, linestyle='-', which='major', color='grey', >> > alpha=0.5) / >> > // >> > /ind = range(len(coverages)) / >> > /rects = ax.bar(ind, coverages, width=0.1, align='center', >> > color='thistle') / >> > /ax.set_xticks(ind) / >> > /#ax.set_xticklabels(contig_names)/ >> > /#ax.tick_params(axis='both', which='major', labelsize=10)/ >> > /#ax.tick_params(axis='both', which='minor', labelsize=8)/ >> > / >> > / >> > / >> > / >> > /#function to auto-rotate the x axis labels/ >> > /fig.autofmt_xdate()/ >> > /plt.setp(ax.get_xticklabels(), fontsize=8, rotation='vertical')/ >> > /plt.show()/ >> > >> > How is it possible to get big charts? >> >> It looks like you are trying to make a figure that is 460 inches by 4 >> inches. How do you expect to display or print it? I think displaying >> it is out of the question, so you would need to use a non-interactive >> backend. I don't know whether ps or pdf can handle those sorts of >> dimensions. >> >> Eric >> >> > >> > Thank you in advance. If you have that much data, a bar chart is probably not the way to go. Maybe try taking the height of what would be each bar and using that as a y-coordinate array then call plt.plot(y)? You'll get a line plot, and the x axis may not make a huge amount of sense, but at least you'll see all your data. Or, perhaps even a histogram? It's hard to advise without knowing your application, but that should help at least a little. Good luck! Best wishes, Damon -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom |