0

I have used the following code to make a scatter plot look like this:

plt.scatter(x, y, marker='|')

enter image description here

Now however I want it to look something like this:

enter image description here

How do I do this? Please do ignore the background and the orange line thingy, that's a different graph altogether. Thanks!

  • You can run the scatter command twice, with two different markers that will be shown on the same image. Just make sure to explicitly set the color for both the same. – JohanC Mar 15 '20 at 00:58

2 Answers2

1

As a workaround, you could scatter twice with the same color. Also, see here.

import numpy as np
from matplotlib import pyplot as plt

xs = np.random.randn(100)
ys = np.random.randn(100)

plt.scatter(xs, ys, color="blue")
plt.scatter(xs, ys, s = 200, marker='|', color='blue')

Resulting in:

enter image description here

hilberts_drinking_problem
  • 11,322
  • 3
  • 22
  • 51
0

It appears to me that what you want to achieve is (or at least looks similar to) a "dot plus error bar" marker style. If you are not plotting error bars, I would strongly discourage that style. If you want to plot errorbars, I would suggest

plt.errorbar(xs, ys, dys, marker='.', ls='')

given that dys are the errors (uncertainties) in the y dimension.

H. Doebler
  • 633
  • 4
  • 9