Skip to content

X-Axis Labels Issue When Creating Bar Charts  #157

@cyruslentin

Description

@cyruslentin

Refer to URL https://cyruslentin.shinyapps.io/kiei-proj/
Giving below code for ggplot2 & plotly via ggplot2 both using Shiny Apps

In the above URL, please refer to IIP > SpecifcMonth > Mode = QuickGraph //normal ggplot graph
Code

fileData <- read.csv("xsmFileData.csv") #csv file is attached herewith
par(mfrow=c(1,1), pin=c(6,4))
xsmDataPlot <- ggplot(dfrIipxData, aes(IndexName, CurrentMonth)) +
   geom_bar(stat="identity", width=0.8, fill=rainbow(length(dfrIipxData$IndexName))) +
   geom_text(aes(label=CurrentMonth), size=4, hjust=0.5, vjust=-0.1) +
   xlab("Index") + ylab("IIP Data") +
   theme(axis.text.x=element_text(angle=60, hjust=1, vjust=1))

Note
This works as required. Note that in this graph, the line "geom_text" is used.
Also note that in this graph the x-axis label are full text.

In the above URL, please refer to IIP > SpecifcMonth > Mode = Interactive //(plotly graph)
Code

fileData <- read.csv("xsmFileData.csv") #csv file is attached herewith ... same as above
par(mfrow=c(1,1), pin=c(6,4))
xsmIipxPlotly <- ggplot(fileData, aes(x=IndexName,y=CurrentMonth)) +
   geom_bar(stat="identity", width=0.8, fill=rainbow(length(dfrIipxData$IndexName))) +
   #geom_text(aes(label=CurrentMonth), size=4, hjust=0.5, vjust=-0.1) +
   xlab("Index") + ylab("IIP Data") +
   theme(axis.text.x=element_text(angle=60, hjust=1, vjust=1))
xsmIipx.py <- plotly("cyruslentin", "ji5rv9ag9k", "https://plot.ly")  # Open Plotly connection
xsmIipx.rs <- xsmIipx.py$ggplotly(xsmIipxPlotly, kwargs=list(filename=paste(thisInstance,"-xsmIipxPlotly",sep=""), fileopt="overwrite", auto_open=F))
tags$iframe(src=xsmIipx.rs$response$url, frameBorder="0", height=450, width=950)

Note
For plotly to generate the graph, the geom_text line(s) have to be commented. (I can live with this)
Further the x-axis labels are some numbers (corresponds to row-number). Why is this happening.

File "xsmFileData" can be found at https://github.com/cyruslentin/plotly.

Any help here would be appreciated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions