![]() ![]() How do I set the x-ticks manually? If I specify a list with the times in quotes () it doesn't work. This creates a plot that has all times on the x-axis set to "0:00". I then tried removing the last two lines: fig, ax = plt.subplots() Is the code not being applied to the graph? 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 So, let us create a python file called ‘plottimeseries.py’ and make necessary imports. We will be using Python’s built-in module called datetime (datetime, timedelta) for parsing the dates. I tried modifying the datetime format directly to remove the month and date, but it seemed to cause problems. First of all, we will create a scatter plot of dates and values in Matplotlib using plt.plotdate (). 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. How to Set X-Axis Values in Matplotlib You can use the following syntax to set the x-axis values for a plot in Matplotlib: specify x-axis locations xticks 2, 4, 6, 8, 10 specify x-axis labels xlabels 'A', 'B', 'C', 'D', 'E' add x-axis values to plot plt. ![]() I recorded my itchiness level over a period of 20 days. import datetime import matplotlib.pyplot as plt x datetime.date(2014, 1, 29), datetime.date(2014, 1, 29), datetime.date(2014, 1, 29) y 2, 4, 1 fig, ax plt. 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 |