![]() ![]() To build a scatter plot, we require two sets of data where one set of arrays represents the x axis and the other set of arrays represents the y axis data. To represent a scatter plot, we will use the matplotlib library. ![]() The dots in the plot are the data values. How do I set the x-ticks manually? If I specify a list with the times in quotes () it doesn't work. Scatter plot in Python is one type of a graph plotted by dots in it. This creates a plot that has all times on the x-axis set to "0:00". Ive got pandas DataFrame, df, with index named date and the columns columnA, columnB and columnC. I then tried removing the last two lines: fig, ax = plt.subplots() Is the code not being applied to the graph? Everything worked as expected in this case because both the date and value variables were appropriately sorted beforehand. Plt.scatter(df, df)īut this just creates the same graph as before, with the dates instead of the hours. I then tried to experiment, thinking that "ax" not being specified was causing problems: fig, ax = plt.subplots() I tried to implement this code, but it raises an attribute error: plt.figure()ĪttributeError: module 'matplotlib.axis' has no attribute 'xaxis' There is also a "notes" column that got cut off, but its not important for this example. Since you guys don't have the csv file I guess I should give you an example of what it would like: date timestamp body part intensity \ Plt.scatter(sorted_df, sorted_df)įor reference, An intensity of 0 means not itchy 1 means mildly itchy (but not enough to scratch) 2 means moderately itchy 3 means very itchy (enough to be distracting) and 4 means extremely itchy, almost like the kind of itchiness you would get from an allergic reaction.Īlso, this code was written for use in a jupyter notebook, which is why it may look a bit wonky.ĮDIT: Whoops. I'm not familiar with the datetime module, so could someone help me out? import pandas as pd Make a list of dates and convert them in datetime format as x. I tried modifying the datetime format directly to remove the month and date, but it seemed to cause problems. To plot data against specific dates on the X-axis using matplotlib, we can take the following steps Set the figure size and adjust the padding between and around the subplots. With my current code, however, it sorts the points by the date, not the time of day. I'm currently using matplotlib and pandas to try and create a scatter plot for all of the hours and minutes of the day, to see if there is any time of the day when I am typically itchy or more itchy than usual. I recorded my itchiness level over a period of 20 days. I'm doing a personal project for my itchy skin. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |