PHPExcel Chart X-Axis Between Tick Marks - phpexcel

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.

Related

How to expand your plot so all labels can be seen without overlapping in R

I have a plot with 50 categories(states) that show on my X axis, but in my output they are on top of each other. I want my plot to be spread out engough/large enough that there is no overlap and you could determine the state value from the next.
NOTE: i used the coord_flip command, so I know that my X-axis is actually my Y in image and vice versa. I am just wondering what function I would use to fix problem.
You can always change the size of the text via themes(axis.text.x=element_text(size=...))...
But the easy answer here is that your plot will change appearance based on the aspect ratio. When you view in Rstudio, you can adjust the size of your plot and you'll see the rearrangement. Additionally, when you save, the plot, play around in particular to the height and width to get the ratio you want. ggsave('filename.png', width=??, height=??).

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...

axis.break does not move with axis 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)

JavaFX XYChart NumberAxis

I'm having problems with the y axis on a custom XYChart. The y axis is a NumberAxis, and I set the tick label formatter to a custom formatter. Auto-ranging is off. When I change the upper bound of the chart and request an axis layout, the old labels remain on the chart. With debug logging, I can see that the custom formatter methods are being invoked, and that they return the correct Strings, but the tick labels on the chart do not update. The only ones that do update are the ones that were not on the axis before. For example, if the range of the y axis was 0 to 3, and then I change the upper bound from 3 to 5, new labels with the correct values will show up at indices 4 and 5. However, the labels for 0 through 3 do not update even though the custom formatter now returns different Strings for them.
I tried taking the custom formatter out of the equation and simply changed the tick label fill to another color when I changed the upper bound of the y axis, and I saw the same behavior (labels for pre-existing indices had the old color, and labels for new indices had the new color). I hope I'm missing something obvious. Any help would be greatly appreciated. Otherwise I may need to resort to recreating the chart whenever the y axis labels need to change.
From what I have found, the tick labels themselves are basically immutable. Once a range is set, it only adds and removes ticks, but doesn't update them. What I did to overcome this is to set the upper bound to the lower bound (effectively removing all ticks), and then setting the upper bound back to the range I wanted, so it would re-create the ticks.

ZedGraph - How to force first and last bars have x-axis labels?

Using Zedgraph (asp.net). I have a bar graph based on datetime x points. The first bar does not have a label. The first label is at the y-axis corresponding to a day before my first day point. I am not too concerned about this. However the second label is at the second bar. I need the first bar to have a label. I do have MyPane.XAxis.Scale.IsSkipFirstLabel = false.
How do I force the first bar to have a label? Why is ZedGraph not putting a label there?
Addition:
I want '5/20' to display for the first bar instead of 5/19 under the y-axis. I don't even have an entry for 5/19.
alt text http://i50.tinypic.com/29ogx0n_th.gif
OK, I don't know if that's exactly what you need, but:
First, adjust your scale ranges manually:
zg1.MasterPane[0].XAxis.Scale.Min = (double)new XDate(2010, 05, 19);
zg1.MasterPane[0].XAxis.Scale.Max = (double)new XDate(2010, 05,30);
This will set the ranges of your scale to show one day before and one day after your data (this is needed to have extra space)
then, set the step:
zg1.MasterPane[0].XAxis.Scale.MajorStep = 1;
zg1.MasterPane[0].XAxis.Scale.FontSpec.Angle = 90f;
This will cause you will have one label for each day. In fact, this is the only way to have more or less control over the labels that appear. I've also changed the angle of labels (in normal position it would overlap).
But it would create the labels for first and last extra days too (margins). So we need to disable these two entries (now it would work, because you've set the ranges manually).
zg1.MasterPane[0].XAxis.Scale.IsSkipFirstLabel = true;
zg1.MasterPane[0].XAxis.Scale.IsSkipLastLabel = true;
If you just want to disable this first and last extra label and leave the rest to the ZedGraph, just ommit the second step. But the outcome could be sometimes unpredictable.

Resources