- So here is the main data frame:
Nr. x J' v'' J'' freq
1 1 0 77 0 76 13430.834
2 2 0 77 0 78 13413.756
3 3 0 77 1 76 13340.366
4 4 0 77 1 78 13323.356
5 5 0 77 2 76 13250.568
6 6 0 77 2 78 13233.628
7 7 0 77 3 76 13161.447
8 8 0 77 3 78 13144.578
9 9 0 77 4 76 13073.008
10 10 0 77 4 78 13056.210
Here is the secondary df:
J77_find
Nr. x J' v'' J'' freq
1 1 0 77 0 76 13430.834
2 2 0 77 0 78 13413.756
3 3 0 77 1 76 13340.366
4 4 0 77 1 78 13323.356
5 5 0 77 2 76 13250.568
6 6 0 77 2 78 13233.628
Here is my code:
p <- ggplot(data = ajkr90_65_sp, aes(x = freq, y =int))+
geom_line() +
geom_point(data = J77_find, aes(x = freq, y = x, colour = “red”))+
geom_text(data = J77_find, aes(label = v”,hjust=freq, vjust=0))
ggplotly(p)
- Here is the graph:
The two thing I’d like to improve on this graph, is legend and interactive labels. I’d like to have legend title to be “J”, and the “red”, I’d like to change to “J77”.
Secondly, I’d like to change the interactive tooltip. Instead of frequency showing, I’d like to have the value that’s in corresponding row in column “J”” in the secondary df, and instead of “x:0”, I’d like to have the corresponding row value of the column “v”” in the secondary df.
I tried using
labs(colour = "J'")
and it worked for legend title, but I need to change the legend values as well. So, I tried using
scale_fill_discrete(name = "J'", labels = J77)
but it didn’t work at all: legend.
For the second problem, i.e., changing the interactive tooltip, I’ve got no idea what to do.
Ieva_Brakmane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.