Hello,
I am trying to generate Density of States plots for some materials that I have data for but I am unsure how to use ggplot2 for this. Here is a picture of how the data is broken up. The x-axis is basically the Energy in eV and each of the other columns corresponds to the grouping of the data. I am trying to get each density plot to overlay onto each of the others but I can't figure out how to do that. All of the examples I have found are for data that also has a category column associated with it but in this case my different categories are the different y-value sets.
Any guidance is appreciated!
I think you need to pivot your data to a longer format using the pivot_longer() function from the tidyverse. If your data frame is named DF, try
DF_lng <- DF |> pivot_longer(cols = TDOS:Cl..s., names_to = "state", values_to="DOS")
There may well be a mistake in that, since I don't have data to test it with.
With the longer format, you can set the fill
or color
aesthetic of ggplot to follow the "state" column.