简体   繁体   中英

matplotlib: scatter plot couldn't connect dot

I am using the following code to plot a scatter plot, and trying to connect the dot in the figure:

   %matplotlib notebook
    import matplotlib.pyplot as plt
    import matplotlib
    matplotlib.style.use('ggplot')
    my_df.plot(x='k', y='score', kind = 'scatter', marker = 'x', linestyle='-')

also tried:

    my_df.plot(x='k', y='score', kind = 'scatter', 'xb-')

But neither of the above works. Anyone knows what I missed? Thanks!

Change your marker kwag, and remove the kind kwag:

my_df.plot(x='k', y='score', marker='x-')
# removing linestyle is optional. It does not help in this case

After some experiments, the code below works:

%matplotlib notebook
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('ggplot')
my_df.plot(x='k', y='score', marker = 'x', color = 'black')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM