Home > Back-end >  How do I set fixed line colors for each data category in ggplotly with reactive data in shiny app?
How do I set fixed line colors for each data category in ggplotly with reactive data in shiny app?

Time:11-23

I am working on a shiny app, which would allow to plot certain type of genomic data.

The app is intended to accept dataframes with fixed column names but of various length. I want that app to display distribution plots of certain genes of interests.

In case of dropdown menu for selecting certain genes, the selectizeInput() on server side is used to increase speed (in real life dataframes there are thousands of unique gene labels).

My app works fine - in terms that it plots distributions of interest. However, in case if only certain conditions are meant to be plotted, the colors of the lines are different than the colors representing given sample if they are plotted together. Also, if some groups are clicked out in the plot area (while ignoring the sidebar menu options for selecting certain conditions) the colors of lines are different than those produced while the dropdown and checkbox are used.

This might be confusing for some users, so I'd like to avoid this.

My question is: how can I prevent switching the colors of the lines in the described situation?

I have found a following thread regarding plot_ly: example

  • Related