简体   繁体   中英

python matplotlib bars graph size

so I ran into a few problems while showing the graph first all the data is on each other I use strings at my x-axis and it looks like this我正在生成的图表

so I wondered if there is a way to stretch it so It won't be on each other

and my second question is if there is a way to open the graph at full screen (I maximized it manually fo the pic)

and the code I wrote to show the graph


plt.figure(figsize=(20, 10))


names_list = [ i.split("-")[0] for i in self.data_dict["data"].split(",")]

values_list = [ i.split("-")[[1]] for i in self.data_dict["data"].split(",")]

plt.subplot(132)

plt.bar(names_list[::-1], values_list[::-1])

plt.suptitle('most commen words ')

plt.show()

You can rotate the x-tick values using the following line:

plt.xticks(rotation=90)

That should make your labels visible. If I understand correctly, you want to increase the size of your figure? You can do so, by increasing the figsize. For example:

plt.figure(figsize=(30, 20))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM