Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"We can't schedule an orgy, it might be construed as fighting" -- Stanley Sutton


devel / comp.lang.python / Re: matplotlib questions

SubjectAuthor
o Re: matplotlib questionsMRAB

1
Re: matplotlib questions

<mailman.490.1630192854.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14788&group=comp.lang.python#14788

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: pyt...@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: matplotlib questions
Date: Sun, 29 Aug 2021 00:17:45 +0100
Lines: 86
Message-ID: <mailman.490.1630192854.4164.python-list@python.org>
References: <000801d79a91$b4d851d0$1e88f570$@SGA.Ninja>
<YSk8GdaBpuz6JIjb@icerm-dld> <005c01d79bbe$410754d0$c315fe70$@SGA.Ninja>
<65c7af17-9982-fb85-f143-b8559759dda0@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de gg7NJK7ES5NRBsKm65h/awGxqdSEdVR9gAE1Ym5BkvZQ==
Return-Path: <python@mrabarnett.plus.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=plus.com header.i=@plus.com header.b=Ks8aqATS;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.040
X-Spam-Evidence: '*H*': 0.93; '*S*': 0.01; 'dates.': 0.09;
'from:addr:python': 0.09; 'graph': 0.09; 'numpy': 0.09; 'ok,':
0.09; 'received:192.168.1.64': 0.09; 'url:stable': 0.09; 'looks':
0.11; 'import': 0.14; '[snip]': 0.16;
'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16;
'hours,': 0.16; 'labels': 0.16; 'message-id:@mrabarnett.plus.com':
0.16; 'properly.': 0.16; 'received:plus.net': 0.16; 'sorted':
0.16; 'subject:matplotlib': 0.16; 'subject:questions': 0.16;
'width,': 0.16; 'wrote:': 0.16; 'to:addr:python-list': 0.23;
'skip:p 30': 0.26; 'length': 0.27; 'text': 0.29; 'header:User-
Agent:1': 0.31; 'received:192.168.1': 0.31; 'header:In-Reply-
To:1': 0.33; 'bar': 0.35; 'code:': 0.35; 'count': 0.37;
'received:192.168': 0.37; 'use': 0.38; 'does': 0.38; 'list': 0.39;
'simple': 0.40; 'days': 0.61; 'here': 0.62; 'showing': 0.63; 'url-
ip:172.67/16': 0.64; 'url:index': 0.64; 'skip:o 20': 0.67;
'received:212': 0.68; 'margin': 0.69; 'indicated': 0.71; 'skip:f
20': 0.76; 'url-ip:104.26/16': 0.79; 'axis': 0.84; 'bars': 0.84;
'bottle': 0.84; 'skip:d 30': 0.86; 'url-ip:104.26.0/24': 0.91;
'url-ip:104.26.1/24': 0.91; 'url-ip:172.67.74/24': 0.91; 'width':
0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1630192666; bh=GNtTAS+y1ZOjI+1LKZeJyU+Y7VPS+qwXcmVtcNCzblU=;
h=Subject:To:References:From:Date:In-Reply-To;
b=Ks8aqATS0tF0QxiBqKs1GXBEDO7U3ZJwA6/NeG+TsgSpi4atJHUa/GTkXEx9RSEDI
JxnJMigotUhZawecVQlPTKtXYNq/xug3Ljth+o6ROn2xBRv893P/p4t8xawA8gZhcS
JtB/9XSWrK/zQfb3J4jX4ZbUgQ557jKTuq1Ymvnyhv70paf5U3bZDdHk+zakR2hDDC
ChqreOYWpnYQEQFLJ2MjtsqbQrnkW0ZlBopXfDEGkoSNvunc70SDLlyBrsXziGaVfd
uhwm4Pib0nKzT1WKV1CnWY1r3By4Adm7T8+MAtBsaiMb/ztITShGsz0bqzi4Kd+p+u
GO6pMH/7FKwqA==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.3 cv=IvmFjI3g c=1 sm=1 tr=0
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=quRTTRacAAAA:8 a=HPNmhGJSAO9azVg3DzwA:9 a=QEXdDO2ut3YA:10
a=U9pn7chn8KCmBO8BZ0xk:22
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <005c01d79bbe$410754d0$c315fe70$@SGA.Ninja>
Content-Language: en-GB
X-CMAE-Envelope: MS4wfGNqqYdFvzrAK0Ss5taQ2qdPUO6DFAA125O51fuJfHoYXAPcZxTyw7dLogbTpvm3BMLECOOBZhXTjGgDasELL/iehthRKqISss+KVTcA3561VxFQx1dJ
7dn1eeLl6V5LgxZc13+GaVFeIQbBkkzZe6XxyH8PSYRl910O7L1Gdf7tOWYtvrNd4pnTOWmULbdx9A==
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <65c7af17-9982-fb85-f143-b8559759dda0@mrabarnett.plus.com>
X-Mailman-Original-References: <000801d79a91$b4d851d0$1e88f570$@SGA.Ninja>
<YSk8GdaBpuz6JIjb@icerm-dld> <005c01d79bbe$410754d0$c315fe70$@SGA.Ninja>
 by: MRAB - Sat, 28 Aug 2021 23:17 UTC

On 2021-08-28 04:39, Steve wrote:
> I would like to know how the data is placed on the Y-axis and at the tops of
> the bars.
> The data is not being shown properly. With some exceptions, it looks as if
> the data is getting sorted independently from the dates.
>
>
> OK, here is the code:
> ==============================================
> # https://matplotlib.org/stable/gallery/index.html
> import matplotlib.pyplot as plt
> import numpy as np
>
> width = 12 #Width of the graph
> height = 6 #Height of the graph
>
> plt.rcParams["figure.figsize"] = (width,height)
> plt.rcParams["font.size"] = (9.0)
>
>
> Count = 0
> datesList = [] # Each date showing end of bottle use
> hoursList = [] # Number of hours
> # daysList = [] # Number of days calculated from hours/24
> countList = [] # simple tally
>
> with open("__Insulin_Tracker.txt", 'r') as infile:
> for lineEQN in infile:
> insulinHours = lineEQN[47:52].strip()
> print("Hours = " + insulinHours)
> hoursList.append(insulinHours)
>
> insulinDates = lineEQN[20:30].strip()
> datesList.append(insulinDates)
>
> # insulinDays= lineEQN[57:62].strip()
> # daysList.append(insulinDays)
>
> Count += 1
> countList.append(str(Count))
> # print(" " + str(Count) + " " + insulinDates + " Hours: " +
> insulinHours)
> x = Count
> count = str(Count)
>
> # Each date indicated the date on which a bottle of insulin has been
> depleted
> # The bar is to show the number of hours that the bottle has been in use.
>
> Labels = datesList
> Xdata= hoursList
>
> Title = ("Bottle List Number of entries: " + count)
> x = np.arange(len(Labels)) # the label locations
>
> width = 0.35 # the width of the bars
> margin = 0
>
> fig, ax = plt.subplots()
> fig.tight_layout(pad=10) # Sets the size of the graph
>
> rects1 = ax.bar(x - width/2, Xdata, width, label='Hours') #Populates the x
> axis
>
> # Add some text for labels, title and custom x-axis tick labels, etc.
> # fontsize = 20
>
> ax.set_ylabel('Hours of use for each bottle')
> ax.set_title(Title)
> ax.set_xticks(x)
> ax.set_xticklabels((datesList), rotation = 90) #Dates at bottom of the graph
> ax.legend()
> ax.bar_label(rects1, padding=0,rotation = 90)
>
> plt.show()
>
[snip]

You're passing ax.bar the contents of Xdata.

What does Xdata contain?

A list of _strings_.

If you want the length of the bars to represent the number of hours,
then they should be numbers.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor