how to add horizontal lines through barplot using ggplot2? - bar-chart

I would like the lines to look exactly like this
I've been able to replicate everything else thus far. just not the actual lines through the bars.
library(ggplot2)
plot <-ggplot(data=df, aes(x=chromosomes, y=size)) +
geom_bar(stat="identity", width=0.1) +
scale_x_discrete(position = "top") + theme(axis.ticks.x = element_blank())+
expand_limits(y=c(0,180)) + scale_y_reverse() '''

Related

Naming bars in barplot

Using this example:
library(ggplot2)
WWII <- function
barplot(table(x,y) + main = "main title" + xlab = "name of X" + ylab = "name of y"+ border = "black" + col = c("colors"))
My question is how can you adjust the names of the different bars, not the "xlab" title, neither the "ylab", but the names down the bars.
I have tried the formula before and I was wondering how to title my bars

New Line '\n' is not working in Typescript with <br/> aslo?

New Line '\n' '' is not working in Typescript
my example typescript code is
this.custPartyAddress = estimation.partyName + ',' + '\n' +
estimation.partyAddress + ',' + estimation.partyLandMark + ',' + estimation.partyCity + '\n' +
estimation.stateName + ', Pin :' + estimation.partyPostalCode + ',' + '\n' + 'India.';
Showing out put is
Raju, Sr Nagar,Near Teample,HYDERABAD Andhra Pradesh, Pin :500032, India.
if above using in place of its showing like Bellow
Raju<br/>, Sr Nagar<br/>,Near Teample<br/>,HYDERABAD Andhra Pradesh<br/>, Pin :500032, India.
html databinding
{{custPartyAddress}}
i tried many ways didt get solution could u please suggest me solution ...
you need to use innerHTML to be interpreted as code
<div [innerHTML]="custPartyAddress"></div>
edit:
instead using {{custPartyAddress}} you can wrap in another div container using example from above (be carefoul, maybe will be necesarry to apply some styles for new container, example width: 100%)
Try to use Template literals with breaks in your text.

Shiny R Add tooltips while hovering over the map

Image of the mapSo I created a map with shiny r. However, I am trying to add tooltips that will display the information when a person hovers over the country. For instance: when it goes on to russia it will display the data on russia as a pop up or tooltip.
I couldn't succeed in doing it. I found couple of codes that adds tooltips to the sidebars however I want to display it on the map while hovering over the countries.
> library(shiny)
> library(shinyBS)
> ui<-fluidPage(
+ mainPanel(
+ tabsetPanel(id="tp",
+ tabPanel("Map View", plotOutput("mPlot", height="560px", width="950px"))
+ )
+ )))
> sPDF <- joinCountryData2Map(data, joinCode='NAME', nameJoinColumn='Country.code')
> server<- function(input, output, session){
+ output$mPlot <- renderPlot({
+ mapParams <- mapPolys(sPDF,
nameColumnToPlot="Truth.Commission.Total", mapRegion="world",
+ missingCountryCol="dark grey", catMethod =
"fixedWith", numCats=20,
+ colourPalette=brewer.pal(20,"YlOrRd"),
+ addLegend=TRUE,
+ oceanCol="light blue")
+ mtext("[Grey Color: No Data Available]",side=1,line=-1)
+ })
+ }
> shinyApp(ui=ui, server=server)
The prior general solutions was made with
>addTooltip(session, id = "someInput", title = "This is an input.",
placement = "left", trigger = "hover")
However, as the countries on map does not have explicit id's displayed on the page, but has the data when plotting the map this solution did not work for me.

Using matchbox to insert PDF in text flow Yes or No?

I am using matchbox to insert images into text_flow which is working nicely, I need to do the same with small PDF charts - before I go down this path just wondering if its even possible ....Yes / No ?
sure, instead of fitting the image you just have to use the PDF page afterwards. So when you go the way of the following PDFlib Cookbook sample http://www.pdflib.com/pdflib-cookbook/text-output/wrap-text-around-images/ (case 4) but just place a PDI page instead of the fit_image():
x1 = p.info_matchbox(matchboxnames[m][0], i, "x1");
y1 = p.info_matchbox(matchboxnames[m][0], i, "y1");
width = p.info_matchbox(matchboxnames[m][0], i, "width");
height = p.info_matchbox(matchboxnames[m][0], i, "height");
p.fit_pdi_page(page, x1, y1,
"boxsize {" + width + " " + height +
"} fitmethod meet position=center");

Is it possible to apply different colours to different parts of an Indic character?

Being inspired by Is it possible to apply CSS to half of a character? I was wondering if something similar could be done with Indic text? As an example, in Sinhala ක + ා = කා (consonant + vowel). Is it possible to render the vowel stroke as a different colour from the base consonant? Other combinations:
ක + ෙ = කෙ
ක + ු = කු
ක + ො = කො
ක + ් = ක්
ම + ් = ම්
ම + ු = මු
ද + ා = දා
ක + ්‍ර = ක්‍ර
ර්‍ + ක = ර්‍ක
ක + ්‍ය = ක්‍ය
ර්‍ + ක + ්‍ර + ො = ර්‍ක්‍රො
I'm looking for an effect similar to this:
Thanks in advance for your awesome answers!
I've had a play with the code from the previous question and come up with this:
http://experimental.haujuseiit.com/vowelstroke.html
If you go to the link you'll see that some combinations don't work but most of them do. The other issue is when the vowel stroke is completely or partially before the consonant. I've had to set explicit widths for "e" (yellow) and "ee" (dark green) which will probably break with different fonts.
I'll post the source code when I've automated the solution.
Improvements anyone?
As far as I know it is not possible to apply a css style to half a character, but I bet you could fake it using two z-indexed graphics, or even glyphs, of differing color. Using one to mask the other.
That would work, but would be a huge amount of work.