![]() ![]() Sc = ax.scatter(df, df, marker = 'o', c = index, alpha = 0.8)Īx.legend(sc. Labels, index = np.unique(df, return_inverse=True) For example: sc2 df.plot.scatter(xdf.delta, ydf. In case the keys were not directly given as numbers, it would look as import numpy as np I have a simple Pandas dataframe: delta, starthour, and endhour are all numpy.int64: type(df.delta0) ->numpy.int64 Whenever I try to use the Pandas methods to do a scatter plot, I get 'Inde圎rror: indices are out-of-bounds'. Sc = ax.scatter(df, df, marker = 'o', c = df, alpha = 0.8) Index = pd.date_range('', freq = 'M', periods = 10), ![]() The advantage is that a single scatter call can be used.ĭf = pd.DataFrame(np.random.normal(10,1,30).reshape(10,3), An example is shown in Automated legend creation. df.plot(logyTrue) dfdfgputranscount > 0.plot(kindscatter, xtranscount, ygputranscount, loglogTrue) import matplotlib.pyplot as plt. (pd._stylesheet)Ĭolors = pd.otting._get_standard_colors(len(groups), color_type='random')įrom matplotlib 3.1 onwards you can use. (I'm also tweaking the legend slightly): import matplotlib.pyplot as plt If you'd like things to look like the default pandas style, then just update the rcParams with the pandas stylesheet and use its color generator. Labels = np.random.choice(, num)ĭf = pd.DataFrame(dict(x=x, y=y, label=labels))Īx.margins(0.05) # Optional, just adds 5% padding to the autoscalingĪx.plot(group.x, group.y, marker='o', linestyle='', ms=12, label=name) For example: import matplotlib.pyplot as plt ![]() It's better to just use plot for discrete categories like this. the points that are not in the filtered set. so how would you basically plot 'the rest' of the data, i.e. But mydata will be missing some points that have values for col1,col2 but are NA for col3, and those still have to be plotted. You can use scatter for this, but that requires having numerical values for your key1, and you won't have a legend, as you noticed. then you can plot using mydata like you show - plotting the scatter between col1,col2 using the values of col3. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |