Stacked bar chart with continuous time-axis as x-axis


We are monitoring 3 processes A, B and C that will always either be in level X, Y, or Z. A protocol records when a process changes levels.

df = read.csv(tc <- textConnection('Time1,Process1,Level1 2013-01-09 18:00:34,A,X 2013-01-09 18:00:34,B,Y 2013-01-09 18:00:34,C,X 2013-01-09 18:00:59,A,Z 2013-01-09 18:01:06,A,X 2013-01-09 18:01:10,C,Y 2013-01-09 18:01:10,B,Z 2013-01-09 18:01:13,A,Z 2013-01-09 18:01:18,A,Off 2013-01-09 18:01:18,B,Off 2013-01-09 18:01:18,C,Off '),header=TRUE) close.connection(tc) df$Time1 = as.POSIXct(df$Time1)

Monitoring was started at 18:00:34 and switched off at 18:01:18. Between 18:00:34 and 18:00:59 process A was in level X, between 18:00:59 and 18:01:06 process A was in level Z.

We would like to show on the x-axis the continuous interval between 18:00:34 and 18:01:18, and three horizontal bars (A, B, C) of equal width that indicate the current process level at the time shown on the x-axis.

Below what we tried last. The overall structure of the chart seems right, but the Time-axis does not make much sense and data is also missing. (We don't need the Off category but it's probably easy to cut it out once the Time-axis makes sense.) Any guidance would be much appreciated.

ggplot() + geom_bar(data=df, aes(x=Process1, y=Time1, fill=Level1)) + coord_flip()

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/oekLX.jpg" data-original="https://i.stack.imgur.com/oekLX.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />


I'm not sure about using geom_bar to do this, but I can get geom_line to do something similar if I increase the size of the lines.

library(ggplot2) library(scales) ggplot(df, aes(x=Time1, y=Process1, group=Process1, colour=Level1)) + geom_line(size=5) + scale_x_datetime("", labels = date_format("%H:%M:%S"))

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/GaZiU.png" data-original="https://i.stack.imgur.com/GaZiU.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />


  • NestJS : database connection (TypeORM) by request (subdomain)
  • Using RECURSIVE CTE with INSERT SELECT to generate table data with MariaDB
  • Can't link compiled shaders to program OpenGL ES 2.0 Android
  • Echo JS onclick fill function AJAX not working
  • Trying to understand setf + aref “magic”
  • How do I debug an Android app that crashes only in Release Mode
  • How to use a boost::mutex as the mapped type in std::map?
  • Ember : downgrading ember with bower install
  • Crossbrowser “inArray” function (without jQuery)
  • How to fix `unknown variable 'sql-mode=ANSI'`?
  • How do I set the FallbackValue for a Binding on UIElement.Margin?
  • Exception in Boto3 - botocore.exceptions.EndpointConnectionError
  • How to create a Graphics2D instance?
  • Installing Rouge on Windows
  • Memory leak when resizing UIImage
  • Cloudflare service worker code to “Bypass cache on cookie” not working
  • JQuery Validation for Duplicates in Form Array
  • how can i have scrollbar when position is negative?
  • Is it possible to use pseudo-elements to make containing elements wrap around an absolutely-position
  • short and easy question on spring nested transactions
  • getting exception when inserting events in android calendar
  • Java anti fillRect (fill everything outside of said rectangle)
  • How to upload an Image onto localhost server whilst path is stored in mysql database?
  • How do I get the standard Vim FTP command to work?
  • Semi-local Levenshtein distance
  • no endpoints available for service \\“kubernetes-dashboard\\”
  • Joining across databases with dbplyr
  • MVC3 Extension for ValidatorMessage
  • Generate a runnable jar and include libraries in it with Maven
  • Shrinking Bootstrap Navbar with logo on scroll
  • Showing image on a acro text field position
  • How to control xtics in gnuplot
  • Splitting ReportLab table across PDF page (side by side)?
  • Java Collections.shuffle() weird behaviour [closed]
  • How to redirect into different page by user type in php and mysql
  • Debug `Unexpected end of JSON input Error` on content script
  • Using Service Component Runtime
  • How do I use TagLib-Sharp to write custom (PRIV) ID3 frames?
  • Firebase: How to read from external DB?
  • CAS 4 - Not able to retrieve the LDAP groups after successful authentication