473,480 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Sort by month in a plot

3 New Member
I am using the following code to plot a graph.

Expand|Select|Wrap|Line Numbers
  1. import pandas as pd
  2. import numpy as np
  3. import matplotlib as mpl
  4. import matplotlib.pyplot as plt
  5. import folium
  6. from folium import plugins
  7.  
  8. crime_data = pd.read_csv('~/Desktop/Assignments/Python/crime_data_sw_police_2021.csv')
  9. crime_data = crime_data.iloc[:,[1,4,5,9,10]]
  10.  
  11. crime_data = crime_data.dropna() # Removing rows with null values
  12.  
  13. count = dict(crime_data["Month"].value_counts())
  14. x = list (count.keys())
  15. y = list (count.values())
  16. plt.figure(figsize = (8,6))
  17. plt.title(label = "Crime Rate by Month")
  18. plt.ylabel("Number of Crimes")
  19. plt.xlabel("Month")
  20. plt.plot(x,y)
  21. plt.show()
However, I get the plot like below and I want to sort it so that the Months are listed as Jan, Feb, March etc. Plot: https://prnt.sc/L8ql76ruULz-

How can I do that? Thanks in advance.
Dec 12 '22 #1
0 9133

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2363
by: Bill Chiu | last post by:
Dear gurus: I need to create a real-time line plot on an html page, without resorting to java, cgi, or anything server-side. I think maybe this could be done with javascript, or dhtml, and most...
30
4110
by: nephish | last post by:
Hey there, i have tried about every graphing package for python i can get to work on my system. gnuplot, pychart, biggles, gdchart, etc.. (cant get matplot to work) so far, they all are working...
6
17666
by: googlinggoogler | last post by:
Hiya, I've got a PIC microcontroller reading me humidity data via rs232, this is in ASCII format. I can view this data easily using hyperterminal or pyserial and convert it to its value...
1
2544
by: Dominick Baier | last post by:
Hi, you are right - Windows needs the password in plaintext to impersonate a user (having to call LogonUser, which requires a password). Thinking about it - it is the only way Windows can do it. ...
0
1629
by: toton | last post by:
Hi, for my project I needs a few plots to visualize the data (mostly x-y plot) . Most of the existing plotting library either copy the data and do plotting, or takes a data pointer to an 2d x-y...
3
2547
by: HowHow | last post by:
I need to sort the "DateOfBirth" by the day (dd) regarless of month (mm)and year (yyyy). I have a query called q_DC_Client, in criteria, I am using this code below: Like "*" & "/" & !! & "/" & "*"...
4
2515
by: jonathan184 | last post by:
Hi I have a perl script, basically what it is suppose to do is check a folder with files. Now the files are checked using a timestamp with the command ls -l so the timestamp in this format is...
4
1766
by: cici | last post by:
I am having trouble sorting secondary keys in a multi-level hash. I have a sample program that exhibits the problem...the following code is sorting New 6 Month before New 1 Month. What am I doing...
0
1343
by: Isabella Cana | last post by:
I need to plot this information. I wrote the code to calculate the frequency of words in a file, but I need it to plot the 15 most frequent words in a bar graph. I really don't even know how to...
0
1400
by: sachinrajiv | last post by:
very urgent help me i am begginer in vb6 .vb have a default code to sort pie chart in ascending or desecending order in mschart like (mschart.plot.sort=(0 or 1 or 2) i want the code to sort...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6886
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4768
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4472
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.