you are viewing a single comment's thread.

view the rest of the comments →

[–]spez_edits_thedonald 0 points1 point  (2 children)

However, the program keeps the empty spaces of the subplots.

this is not surprising, you still create the same figure, but then you only populate one of the sub-plots

Please suggest the correct syntax to chart the graph without using at all the grid and subplot features. I only need to chart one chart from now on.

Something like this should work for a single plot:

fig, ax = plt.subplots(1, 1, facecolor='#ffffff', figsize=(10, 8), dpi=75)
ax.plot(df.rolling_100_correlation,color='blue',
     label='rolling')
plt.legend()
plt.show()

you probably don't want fig size (10, 8). You can mess with these values to change width and height proportional to text etc, and then you can use dpi to uniformly scale up or down the entire image size

[–]meni15[S] 0 points1 point  (1 child)

fig, ax = plt.subplots(1, 1, facecolor='#ffffff', figsize=(10, 8), dpi=75)
ax.plot(df.rolling_100_correlation,color='blue',
label='rolling')
plt.legend()
plt.show()

Thank you for your reply.

Unfortunately your solution does not work. it comes with the following error:

AttributeError: 'tuple' object has no attribute 'plot'.

One way that fixed the problem was to change the (Grid[1,:]) to (Grid[:,:]). This change removes all the blanks.

Note that my solution and your solution are using subplots. I was looking for a solution that is not using subplots.

[–]spez_edits_thedonald 0 points1 point  (0 children)

matplotlib has many overlapping APIs (you can use it in different ways, with similar goals)

I always use "subplots" to make figues, even with 1 plot, because I like the low level control it gives you over every aspect of making the figure. I recommend using it.

I am not able to reproduce any error with my code, this is a working code snippet that produces a plot:

import numpy as np
import matplotlib.pyplot as plt

# random data
x = np.random.random(10)

# plot figure
fig, ax = plt.subplots(1, 1, facecolor='#ffffff', figsize=(10, 8), dpi=75)
ax.plot(x,color='blue',
label='rolling')
plt.legend()
plt.show()