0

I have been trying to achieve something like this: Example

So far this is what I have tried:

crimes.Month = pd.to_datetime(crimes.Month, format='%Y/%m')

crimes.index = pd.DatetimeIndex(crimes.Month)

import numpy as np

crimes_count_date = crimes.pivot_table('Month', aggfunc=np.size,columns='Crime type', index=crimes.index.date, fill_value=0)

crimes_count_date.index = pd.DatetimeIndex(crimes_count_date.index)

plo = crimes_count_date.rolling(365).sum().plot(figsize=(12, 30),subplots=True, layout=(-1, 3), sharex=False, sharey=False)

Note- on the x-axis I would like to display each year/month: 2017/08

Current output below, is not showing all months/year or any lines for the crime types Current Ouput

1 Answer 1

2

Not sure how your data looks.

But python has a nice way of doing subplots:

import matplotlib.pyplot as plt
plt.figure(figsize=(16,8)) ## setting over-all figure size (optional)
plt.subplot(2, 3, 1) 

##  this creates 6 subplots (2 rows and 3 columns)
## 1 at the end means we are in the first subplot.. then...

plt.plot(x1,y1) ## for well-selected x1 and y1
plt.subplot(232) ## the same as subplot(2, 3, 2) - you can use this when values have
                 ## one digit only; now we are in the 2nd subplot
plt.plot(x2, y2)  ## this will be plotted in the second subplot

## etc. ...

plt.subplot(236)
plt.plot(x6,y6)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.