axis.break does not move with axis R - r

I want to plot the vector 4:10 but from 0 to 10. I don't like the large gap in produces, and I want to create my own style of plot, so I write the code:
plot(4:10,axes=FALSE,ylim=c(2,10),xlim=c(0,8))
axis(1,pos=2)
axis(2,pos=0,at=seq(2,10,2),labels=c('0','4','6','8','10'))
In order to not mislead the audience, I want to put in an axis break using axis.break() from plotrix. Unfortunately, when I add
axis.break(2,2.5)
on my plot, I don't get the break where my axis is but where it would be if I used the default axis. How do I get axisbreak() to move with my axis? Or else, how do I put an axis break where I want it?

Add pos=0 to your axis.break:
plot(4:10,axes=FALSE,ylim=c(2,10),xlim=c(0,8))
axis(1,pos=2)
axis(2,pos=0,at=seq(2,10,2),labels=c('0','4','6','8','10'))
axis.break(2,2.5,pos=0)

Related

How do I add an axis break in Complexheatmap's upset plot?

I am making an upset plot using the ComplexHeatmap package (https://jokergoo.github.io/ComplexHeatmap-reference/book/upset-plot.html#upset-making-the-plot). Some of my bars are an order of magnitude higher than the rest. I would like to add a break in the set size and intersection size axis. Is this possible? I could not find a function for it.

PHPExcel Chart X-Axis Between Tick Marks

I'm working on an old script and I've hit a problem for a configuration that does not appear to be documented. I have a dynamically created bar chart. The bars are vertical. Everything is fine except the position of the bars on the X axis. The first and last one are half cut off. I can fix it easily after producing the spreadsheet. I click on the X-axis and switch the position to "Between tick marks" instead of "On tick marks." I cannot find anything in any form of PHPExcel documentation for setting the position of the X axis to "between" instead of "on." Does this setting exist?
PHPExcel has been replaced by PHPSpreadsheet, but there are cases where it is not possible to change from PHPExcel to PHPSpreadsheet.
The option that must be set is "crossBetween" for the X Axis. PHPExcel does not make this a customizable option. It is hard-coded in Charts.php with the value "midCat". That setting places the first bar directly under the Y axis and the last bar hanging off the right side of the chart. Each bar is cut off. To place the bars between the ticks, edit Charts.php and change the entry for "midCat" to "between". You should only find "midCat" once in the file. This will hard-code all charts to be between the ticks. Change it back if you want it back to what it used to be.
The proper fix is to make this an option you can change. That requires editing multiple files. The Axis object needs a cross_between option. Then, a setter is needed to update that option. The writer needs to pull from that option instead of hard-coding the value. Chart lets you get the X Axis, but you can't set it once you update an option. So, you need a setter for the X Axis for the chart. Then, you can create a chart, get the X Axis, change the crossBetween value, and set the updated axis in the chart.

Labelling X and Y axis in Dymola plot

I have drawn a plot using "plotArrays" function in Dymola. I would like to label X-axis in meters(Ideally, I need it to be flexible so that I can later change it to millimeters, micrometers, etc..). I want to label Y-axis similarly in volts which I have done already using
plotArrays(x_axis,phie,legend=names,units=fill("V",size(phie,2)));
and I can read the values in volts and also change to mV etc.. However, its not 'visible' in Y-axis as you can see in the plot below. So, How can I label the axes separately?
Thanks a lot!
I don't know any more efficient possibility than this:
createPlot(id=1, erase=false, grid=true, leftTitleType=2, leftTitle="myLabelY", bottomTitleType=2, bottomTitle="myLabelX")
with:
id being the number shown in the original plot
erase=false to ensure that the content is not modified
grid=true (re-)enabling the grid
*TitleType=2 saying that there is a custom title
*Title being the string to put there
This will result in the plot being resized to the default size. You can use plotSetup() to get the current setup, including position, which you can then pass (manually) to the createPlot() command to result in the original size again.
Not very elegant, but I don't know any other possibility...

How to plot just one axis label in R?

A beginner question: I currently have some plots that look like this.
I'm keeping the plots free of other annotation because I have to fit a lot of them onto one page and specific values aren't important, just the general trend that the red line is to the right of the black one. However, I'd like to be able to indicate that the dashed line in my plot actually represents zero, like so:
Is there any way to tell R to only display that value on the x-axis labels? I don't think using text() would be a good idea because it relies on absolute coordinates, but I'm not really sure how to work with axis options to make it do what I want.
Try:
axis(side = 1, at = 0)
See ?axis for details.

Horizontal grid not matching y axis ticks

I have the following data:
x=c(2.880262,3.405859,3.613575,3.744480,3.682059,3.694075,3.758320,4.034290,4.202741,4.309383,4.996279,5.981309,5.103148,4.926363,4.696024,5.522913,5.330382,4.434304,5.154567,6.247156,8.612752,9.996526,9.606994,10.303496,5.954970,5.688171,6.340349,6.252854,6.355642,5.988570,7.317148,11.664384,14.231579,16.489029,23.100640,20.280043,21.562793,24.311327,23.735198,23.796386,23.118181,23.269722,19.886981,20.000975,19.967642,24.278910,17.447721,14.536114,20.646378,19.096832,20.258060,19.803196)
y=1:52
w=c(-2784,-2897,-2897,-2066,-2466,-2466,-2466,-2466,-2102,-2102,-2102,-2202,-2094,-2094,-2094,-2094,-1691,-1691,-1691,-1691,-1691,-1674,-1774,-1774,-2019,-2019,-2019,-2019,-2019,-1988,-1988,-1988,-1988,-1988,-1888,-1888,-1888,-1888,-1888,-1888,-1888,-1488,-2051,-2051,-2051,-2051,-2315,-2315,-2315)
v=1:49
When I try to plot these, my grid does not match the tick marks. Is there a way to fix this in base?
plot(y,x,type='l',col='blue',log='y')
grid(NA,NULL)
Resulting plot:
And the other plot:
plot(v,w,type='l',yaxt='n')
grid(NA,NULL)
axis(2,pretty(w),format(pretty(w)/1000,big.mark=','))
Result:
I put both up because I am using different techniques to label the y axis, and one is a log chart while the other is not. By the way, I have hundreds of other data sets that are placing the grid lines by the tick marks. It is just these two that are not matching grids to ticks.
For the first plot, just use equilogs=F.
For the second plot, since you are using non-default axis ticks, I think you'll have to resort to abline like it says in ?grid. Good luck!

Resources