0

Is there any way to get a dotted background like the following picture?

enter image description here

The only method I know is to upload a picture of dots and fill in the plot with that picture according to this post:Adding a background image to a plot with known corner coordinates

Community
  • 1
  • 1
Meng
  • 1,148
  • 5
  • 15
  • 23
  • Do you only want to have a dotted background or you want to do something else? You could use `grid`, you could use `scatter`, you could use `plot`... Please, try to explain better what you want to do. – kikocorreoso Feb 26 '16 at 20:24
  • I want a dotted "background".(It's not a dot/scatter plot. There is no data. It is a background.) – Meng Feb 26 '16 at 20:33
  • Well, define background :-) Do you want to plot something 'over' the 'background'? – kikocorreoso Feb 26 '16 at 20:37
  • Yes. After I have the background, I want to have some basic plotting over that background. – Meng Feb 26 '16 at 20:49

1 Answers1

0

For instance, with this ugly hack you can have dots wherever you want:

import matplotlib.pyplot as plt
import numpy as np


y = np.random.randn(100) * 100
x = np.arange(len(y))

for xi in x:
    ybg = np.arange(np.int(y.min())-1, np.int(y.max()+1))
    xbg = np.repeat(xi, len(ybg))
    plt.plot(xbg, ybg, '.k', alpha = 0.25)

plt.plot(x, y, 'b', lw = 3)

Controlling xbg and ybg you can control where your dots will be plotted so you don't have to mind about an image background.

kikocorreoso
  • 3,999
  • 1
  • 17
  • 26