-2

I am trying to plot lines with markers, but pandas is only returning the markers. Any solution for this?

sns.set()
sns.set(rc={"figure.figsize": (16, 8)})

df_payback_days_to_start.plot(kind="line",legend=False, marker=".")

plt.xlabel("Days for Event Start")
plt.ylabel("Kambi Payback")
plt.title("Payback Over Time")
plt.show()

"img" So, as you can see below, my data set has a few nulls. That is the reason why most lines are not plotted, it doesn't connect when there are nulls.

+---------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+-----+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+
|   event_id    | 1004179030 | 1004179031 | 1004179032 | 1004179033 | 1004179034 | 1004179035 | 1004179036 | 1004179037 | 1004179041 | 1004179042 | ... | 1004180739 | 1004180740 | 1004180741 | 1004180742 | 1004180743 | 1004180744 | 1004180745 | 1004180746 | 1004180747 | 1004180748 |
+---------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+-----+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+
| days_to_start |            |            |            |            |            |            |            |            |            |            |     |            |            |            |            |            |            |            |            |            |            |
| 0.006250      | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | ... | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        |
| 0.004861      | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | ... | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        |
| 0.003472      | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | ... | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        |
| 0.002778      | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | ... | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        |
| 0.002083      | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | ... | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        | NaN        |
+---------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+-----+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+
wazo
  • 311
  • 2
  • 16
  • Have you looked at this? https://stackoverflow.com/questions/8409095/matplotlib-set-markers-for-individual-points-on-a-line (possible duplicate) – Evan Jan 04 '18 at 17:43
  • Just looked and don't think the fix is in there – wazo Jan 04 '18 at 17:51
  • 4
    Please take some time to review [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). In this specific case I cannot reproduce this problem, and can't offer much help as a result. – Grr Jan 04 '18 at 18:02

1 Answers1

1

Check your setup. The code below generates the right type of plot:

import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt

sns.set()
sns.set(rc={"figure.figsize": (16, 8)})

df = pd.DataFrame(np.random.random((10,10)))
df.plot(kind="line",legend=False, marker=".")

plt.xlabel("Days for Event Start")
plt.ylabel("Kambi Payback")
plt.title("Payback Over Time")
plt.show()

example plot

mtd
  • 2,224
  • 19
  • 21
  • What do you mean by "check my setup"? If you notice on the right hand side of the graph there seem to be a couple lines. It just doesn't reproduce throughout the whole graph. Do you know a logical reason for this? – wazo Jan 10 '18 at 20:25
  • Figured out the problem! Thanks – wazo Jan 11 '18 at 00:49