Plotting time on X axis in excel - excel

I have done 24 hour measurement and results obtain contains around 1400 entries. Now I want to plot those results in such a way
That x axis represent my time and y axis the corresponding value.
My x axis should be divided into 24 sections each representing 1
hour.
My exact start time is 14:00 and end time is next day 14:00.
For more clarification I am adding a simple version of my data here below
And resulting Plot I am getting is this.
I look forward to your answers. Thank you.

If the time values go across midnight, you need to add a date part to the time value, so they can be plotted correctly as before and after midnight. At the very least, the time values for the first day should have a 0 before the decimal, e.g. 0.875 for 9 pm, and the values after midnight should have a 1 before the decimal, e.g. 1.125 for 1 am, so it falls on the next day and not the same day as the 9pm value.
Then plot an XY Scatter chart.
Work out what Excel's internal number (date/time value showing in General format) is for the desired X axis minimum, maximum and major/minor increments and format the x axis accordingly. Set the number format to hh:mm
Edit: For example: you want the minimum X axis value to be 24-Dec-2015 11 pm. Write that into a cell as a date/time. Format the cell to General. Then use the number you see in the format dialog for the X axis minimum.
If you want the major unit to be 1 hour, write the time value 1:00 into a cell and format it with general. Use that number in the dialog for Major.
Format the X axis labels to show time values, not dates.

Related

create stacked column chart to show running time

I have data on 5 runners for 1 week; start time and end time in a race. I want to graph how long it took each runner to finish the race
when I subtract the cells for start and end time, I get a result as 3:00 AM instead of 3 hours. I think this is why I'm having an issue creating a stacked column chart
how can I subtract 2 timestamps and get it to spit out just the hours instead of another time stamp?
I want the date on x axis and time to complete the race on y axis
thank you
here is a sample of the data
https://imgur.com/xRyDynl
i want a stacked column chart that has dates on the x axis. so 1/1 will have 1 bar that has 30 mins for racer 1, 35mins for 2, and 40 mins for 3

How to make a categorical count bar plot with time on x-axis

I want to count the number of occurrences of categories in a variable and plot it against time.
The data looks like following:
Date_column Categorical_variable
20-01-2019 A
20-01-2019 B
20-01-2019 C
21-01-2019 A
21-02-2019 A
22-02-2019 B
........................
23-04-2020 A
I want to show that in month of Jan I had 1 occurrence of B/C whereas 2 occurrences of A. In feb, I had 1 occurrence of A/B and so on. The bar plots can be stacked to know the total number of occurrences.
I've been very close to it. But haven't been able to draw plot out of it.
df['Date_column'].groupby([df.Date_column.dt.year, df.Date_column.dt.month]).agg('count')
The other way is to change the dates to 1st of every month, and then group by to count a occurence. But I'm unable to draw plot out of it.
df.groupby(df['Date_column'], df['Categorical_variable']).count()
Use crosstab with Series.dt.to_period:
df['Date_column'] = pd.to_datetime(df['Date_column'])
df = pd.crosstab(df['Date_column'].dt.to_period('m'), df['Categorical_variable'])
df.plot.bar()

Labeling axis. Convertion from Excel. Convert data into String

How would you plot an A vs B graph,where A and B are columns in Excel such as
A
Red
Green
Blue
and
B
1:00 AM
2:00 AM
3:00 AM
for 3*3 graphs I use
set(gca,'XTick',1:3);
set(gca,'XTickLabel',{'Red','Green','Blue'});
set(gca,'YTick',1:3);
set(gca,'YTickLabel',{'1:00 AM','2:00 AM','3:00 AM'});
However manual entering for 1000*1000 would be a mess.
So my question is:
How do I convert values Red Green Blue from column A as {'Red','Green','Blue'}? (in order to use them in set(gca,'XTickLabel'...)
I tried using
color = xlsread(fileName, 'A1:A3');
but it didn't convert the data into the right format.
Any help is appreciated.
The second output argument of xlsread contains text data. The first contains only numerical:
>> [nums,colors,raw] = xlsread('colorData.xlsx','A1:A3');
>> colors
colors =
'Red'
'Green'
'Blue'
UPDATE: The times read by xlsread are in Excel's serial date format (a numerical representation). They can be converted to a string with the time using datestr.
>> nums
nums =
0.0417
0.0833
0.1250
>> datestr(nums)
ans =
1:00 AM
2:00 AM
3:00 AM
These are actually dates, using Jan. 1 1900 as time zero. So, but giving just a time, it a number assuming this day. However, MATLAB uses Jan-1-0000, so if you have dates as well as times, convert them using datestr(t + datenum('30-Dec-1899')), where t is the numerical value with the serial date number.

how to put the different times in y axis in matlab

greeting for every one,
I have data in excel file and i want to draw a plot in Matlab in which the Y axis represent the time with starting time in 10:45 for 24 hours i.e, from 10:00 am to the next day in 10:00 am. The x-axis represents the excel file data( the values of frequencies during 24 hours)
how to put the different times in the y axis showing the values of time in the formula of time(00:00 am/pm) using matlab?
if i use this code: ylim(subplot2,[1 24]) and xlim(subplot2,[170 230]) it will be plotted but the y-axis shows only the hours from 1 to 24 hours and i need the y-axis from 10:45 am(starting time) to(10:45)am in interval 24 hours
You can create custom tick labels by specifying tick strings with the command:
time_cells = {'10:45','11:45',...,'9:45','10:45'};
set(gca, 'YTickLabel', time_cells)
Where gca is the handle of your current plot (axes), and the time_cells is a cell array containing all your required tick labels (without the ellipse). It is probably easiest to generate this using a for-loop to create the numbers you want, and then num2str to convert to the strings you need.

how to plot time points in a day on excel

I have a set of points as time of day like
05:36:37
06:31:41
06:38:24
06:39:42
07:03:47
07:04:18
07:09:28
07:28:40
07:29:20
07:29:49
07:31:57
.....
Now i would like to plot this for an entire 24 hour range in a day.
Basically x axis is the 24 hour range and i need a point for every above time on the y axis. ofcourse y axis may not vary, but i am loooking at finding the coverage as to, in a day, when did the even occur more times. Its the same event. If there are better ways to represent you can also suggest that.
Let's say your data is from A1 to A_N.
in column B enter =HOUR(A1)
in column C enter =MINUTE(A1)
Then Insert -> XY Scatter Chart

Resources