Using google sheets, I am trying to plot times between 9pm and 3am (sleeping time every night), with the x axis being each calendar date/day.
But the scale puts items just after midnight at the bottom of the y-axis (y is the time axis, x axis is the day), because of the timing (0:10) is 10 minutes later than midnight and I want it to reflect that on the graph.
The two graphs are waking and sleeping times.
Waking makes sense, sleeping does not:
The only way seems to be put an if else and change format completely converting time format to integer and then multiplying to get a number close to 24 hrs (and then 1am is 25, 2 am is 26, etc).
Is there not a simpler was to change the axis for time? Does no one else log times either side of midnight?
The two images below show the formula, and the chart data:
Related
We are using chart.js lib Version 3.7.1.We have multichart graph with line and bars. Both using time scale on x axis, but one has one month value, while second has one day value.
example:
const dailyAxis = [27-05-2022, 30-05-2022, 31-05-2022, 01-06-2022, ... 07-06-2022];
const monthlyAxis = [31-03-2022, 30-04-2022, 31-05-2022, 30-06-2022];
The problem is, that daily values could start from the middle of the month or one month could have 20 daily values, other could have 30. Is it possible to align two charts, to have first daily point at start of monthly bar and last point at the end of monthly bar, no matter how many daily values we have?
I am trying to make a basic line & point plot in Bokeh (0.12.3) using the following code. I have set the x_axis_type as 'datetime' and I am plotting a (random) variable vs. a pandas (0.19.0) datetime64 dtype that is the index of the dataframe (i.e. a timeseries).
The problem I see with the plot is that the dates are not properly aligned. In the time series, the max date is 2016-11-06, however, the last scale tick is for Nov 16, and there is a point aligned to what appears to be several days after that.
Curiously, when zooming in the plot, the alignment looks correct!
Is this a bug, or am I doing something wrong for this plot? Do I need to be more specific in how the x-axis should be rendered?
Also, I really think the scale increments should be in equal number of days. However in this case, Bokeh plots the scale increments to be on the same day of esch month (which is a varying number of days increments). I have seen this before in other plots, and that default can hamper interpretation.
Appreciate any help on this. Here is the code and the screen shots that demonstrate the issue:
# imports & config
import pandas as pd
import numpy as np
from bokeh.plotting import figure, show, output_notebook
output_notebook()
# create a times series dataframe
rng = pd.date_range('2016-07-24', periods=16, freq='W')
df = pd.DataFrame(np.random.randn(len(rng)), index = rng, columns=['Y'])
# view the tail of the data to compare to plot
df.tail()
# make and render the plot
p1 = figure(x_axis_type='datetime',
title='Y vs Week Ending',
plot_width=700, plot_height=400)
p1.xaxis.axis_label = 'Week Ending'
p1.yaxis.axis_label = 'Y'
p1.line(df.index, df['Y'])
p1.circle(df.index, df['Y'])
p1.yaxis.minor_tick_line_alpha=0
show(p1)
the last scale tick is for Nov 16, and there is a point aligned to what appears to be several days after that.
That tick is for Nov 2016.. it's not very intuitive, but the year is contracted into the label.
Knowing this may change your perspective w.r.t. this comment:
...I really think the scale increments should be in equal number of days. However in this case, Bokeh plots the scale increments to be on the same day of [each] month...
What it's done is change the base unit from day to month, which is probably the more correct approach.
Given the data arrangement in the image below (from google sheet) I tried to draw a chart showing time consumed by each activity, each activity has a start time, the end time of an activity is the start time of the next activity, I couldn't find a way to visualize such arrangement, is it possible ?
Update: Solution
This is what I reached now
Also I don't have to write end time, here is how I did it
End
=INDIRECT(ADDRESS(ROW()+1,COLUMN()-1))
Duration
=C:C-B:B
Minutes
= D:D * 24 * 60
Note: To draw the chart I had to move the "Minutes" column to the right, i.e labels column has to be on the left for the chart to draw properly.
After that you can hide helping columns C and D as they are just created for intermediate steps.
Yes, you may build a Pie chart based on time entries, but you need to convert time format into number format.
select column with time
go to menu Format → Number → Number
Or, for more visual, convert time formatted numbers into number of minutes:
= Time * 24 * 60
And then draw chart:
I have a 3D camera that could give Matlab information about the distance of an object in real time after the command distance=function1(Device)(I have omit this function since it is not important here).
I would like to make a program that shows the object moving when time changes.
I have already succeeded in using:
t1=clock;
while......(in a loop)
distance(i)=step(Device);
t2=clock;
times(i)=etime(t2,t1);
plot(times,distance);
end
to show the object moving. However, the X axis in this figure is the comparative time, which means the x axis begins with 0 seconds and ends with (t2-t1) seconds .
Now I try to find a way to change the X axis to the absolute time or the cpu time.
Like the following picture:
I'd like to change the comparative time(in black fonts) to the absolute system time (in red fonts).
I have try ' datetick' but it doesn't work properly?
Is there any way to do this?
The following creates a string out of the clock, plots distance, then attempts to change the labels based on the text strings each iteration. I tested a simple instance of it in MATLAB.
while ... (in a loop)
distance(i)=step(Device);
t2=clock;
tint = int8(t2(4:6)))
stamp{i} = strcat(int2str(tint(1)),':',int2str(tint(2)),':',int2str(tint(3)))
plot(distance)
set(gca,'XTick',1:i,'XTickLabel',stamp)
end
As far as getting the AM and PM to show, well, you'll have to do some extra witchcraft but it should be possible, based on the clock values. Then just append AM or PM into the stamp{i} assignation.
Hint, if t2(4) > 12 you are looking at PM. Else, AM.
One limitation with this is that the more iterations you do, the more crowded your X-Axis is going to become.
I've a dynamic timeseries chart to which some value is added every 20 seconds. I want to set the width of the plot to something like say 30 minutes so that my chart starts showing a "30-min canvas/plot" starting from the left hand side until it fills up the whole plot. After every 30 minutes, I want to clear up the old data and only show the latest 30 minutes data which means at any given point of time, my chart will only show data of latest 30 minutes. I've already created chart and its working great except that the starting domain range gets fixed to the point from where it started even after couple of hours.
Get upperbound after 30 minutes, then set lowerbound to the upperbound and the new upperbound to the old upperbound+30minutes?
http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/ValueAxis.html#getUpperBound%28%29