How to plot and present the multiple values whenever user placed mouse on point it using plotly and

53 views
Skip to first unread message

Manohar Reddy

unread,
Sep 19, 2016, 6:20:05 AM9/19/16
to ggplot2, Manohar Reddy

Juergen Loeffler

unread,
Sep 19, 2016, 9:17:24 AM9/19/16
to ggplot2, manu.r...@gmail.com

Dear Manohar,

 

If I understand correctly, you want to display the value of an additional variable which is not directly used to create the plot.

You can use the “text” aesthetic in ggplot and the “tooltip” option in ggplotly.

 

In your case (note that I also added minimal HTML formatting code):

 

t5 <- data.frame(list(OrderNumber = c(1005,10010,10011,10012,10013,10028),

                      OrderDate=c( "2015-05-28 10:13:19", "2015-05-29 12:18:46","2015-06-01 05:18:06","2015-06-01 05:38:30","2015-06-01 05:44:13","2015-07-16 14:34:09"),

                      TotalCost=c(44.9800,12.8993,38.0000,38.0000,9.5000,16.5743)))

 

library(ggplot2)

library(plotly)

library(scales)

g <- ggplot(data = t5, aes(x = OrderDate, y = TotalCost, 

                                                    text=paste("OrderNumber=", OrderNumber, "<br>",

                                                                            "OrderDate=", OrderDate, "<br>",

                                                                            "TotalCost=", TotalCost, "<br>",

                                                                             sep="")))+

  geom_line(stat = "identity",color="blue") +

  geom_point() +

  scale_fill_manual(name = "legend") +

  ylab("Order Cost in $") +

  xlab("OrderDate") +

  ggtitle("OrderDetails")

 

ggplotly(g,tooltip="text")



Is this what you wanted?

 

Best regards, Juergen

Manohar Reddy

unread,
Sep 19, 2016, 1:09:10 PM9/19/16
to Juergen Loeffler, ggplot2

  Dear Juergen,

 

   Thank you so much for your answer, I’m looking for same kind of report but in that graph(PFA) there is no lines even if I add “geom_lines ()”.Can you please help me to how to add lines on that.


Manu.

--


Thanks,
Manohar Reddy P
plotly_orders_missing_lines.PNG
Reply all
Reply to author
Forward
0 new messages