ggplot: Axis Text Label Width? - r

I'm currently struggling immensely to get the axis text in a graph that I'm designing to automatically format such that it cuts off when it becomes too long. I would ideally implement some sort of character cut off, but I'd ideally prefer to refrain from sticking '\n' after every 2 words. I've dug through the libraries for solutions, but couldn't find any.
It'd also be lovely if I could somehow prevent the graph from shifting upwards, as it makes it incredibly difficult to compare with the 'other' graph next to it.
I've largely been using ggplot and theme settings to make the changes.
Is it possible to make these changes? (1. width limit on axis text, 2. stop area expansion)

Related

Plotly - I want to color the Y axis tick text based on value

My questions is similar to one that's been asked but in a different language. I'm using plotly in python, to build dash web app dashboards and I have graphs with a y-axis range from negative values to positive values. I would like to leave the positive values black, but I would like to change the negative values to be red (preferably with parentheses around them as well, but the red color is the more important item).
From my research, it seems that there is no native way to do this. I'm up for a complicated solution if that's what it takes. When I inspect the element in the web interface, I can see the html code that shows the RGB values for the text of each tick, but I cannot seem to figure out where I can modify the colors independently of the other tick texts. I've started looking for the source file that is used to format these things so that I can potentially add the logic to it.
The similar question is here and it was asked for JavaScript: Plotly - I want to color each X Axis value in different color based on condition
Any help is appreciated.

Change the spacing in R dendrograms

I want to create a nice dendrogram for my cluster. Since I work with over thousands of data entries, the resulting dendrogram looks kinda sad. The Screenshots show, that too much space is used to display the splits, while not enough space is left to show the important information at the bottom.
I want to compress the space used for for the graph display and increase the space used for the labels. Is there an option for this? If I only decrease the the size of the image, he will simply cut the labels at the end.

How to create a dyraph with multiple x-axis labels?

I'm working with a lot of rank data that would benefit from a way to simultaneously display its respective year on the x-axis. For example, I want to create the following graph adapted from the dygraph gallery:
Note how the rank information (red arrow) for a particular weekend (green arrow) are both displayed on the x axis.
I know this might not be possible with dygraphs now, at least it wasn't available in these demos, so I guess my follow up question would be are there any plans to make this possible (how about in the [r] {dygraph} package)? Apparently a plotter called flot can do this.
UPDATE 1
If indeed this feature does not exist yet, then the following, although potentially obvious to Dygraph developers, is a thought for accomplishing the task easily (perhaps I'm wrong). At first I thought it would be necessary to provide input data of the form shown in Table A
However such input is a major deviation from the existing Dygraph parser model who expects one abscissa. Such suggests that a modification to the parser to accept a "Dual Label" option, requiring that both labels be contained in a single abscissa element as in Table B, would be easier. Thereafter, with the option specified, the parser would manage CSV as it usually would with the exception that it is now "bin cognizant" and detects division between labels 1 and 2 by use of an acceptable delimiter (in this case a single quotation mark - maybe not the best choice) and divisions between label 1 abscissa elements by name change. Behind the scenes each point gets its unique x coordinate and the "Dual Label" option causes the dygraph to visually scoot up a couple pixels to accommodate an extra label. Not sure how to handle full zoomed scrolling put simply leaving a label 1 element centered until an adjacent label 1 element comes on screen is an option.
Dygraphs rule!
There's no simple way to do this with dygraphs now. As you say, there's a fairly deep assumption that there's only a single x-axis.
Your best bet would be to either modify the existing legend plugin to do this, or to create a new plugin which renders just the "Weekend 1", "Weekend 2" line. While the plugins API isn't official yet, it is at least somewhat documented.
If you get this to work, please share your code!

plot every tick on axis[SAS]

I have dataset include about 100 observations, say all of them are in (x,y) format, all of y is in integer format. I need proc sgplot to make a graphic about them. The range about my y is from 1 to 150. I hope I can force the graphic to show every corresponding y value on the y-axis instead of automatically reducing the ticks to a small number in order to show them clearly. For example, if the first five value of my y is (1,3,4,6,7,....), I hope the y tick shows exactly (1,3,4,6,7,....) instead (1,5,...).
I tried
yaxis value=(1 to 150 by 1) valueshint display=all;
It does not work as maybe I have too many observations. I know the result maybe overwhelming, but I just want to see the result. Thanks.
You don't say if you're using SAS/GRAPH or ODS GRAPHICS (SGPLOT etc.), so I'll answer the latter which is what I know; the answer should be useful for both in concept.
You likely cannot get SAS to plot so much on the axis unless the axis is very large itself. This means you have two options.
Raise the size of the graphic produced a lot in terms of pixels(and then shrink that to a usable size via image physical size, or using an external tool). Not necessarily usable in all cases, but produces a very high resolution plot (which is very big size-wise). This page explains how to do that for ODS graphics (use image_dpi as a high number, and width and height in inches as a normal number), and this page explains for SAS/GRAPH. You may need to make your font small to make it work (if you're adding numbers, which I assume you are), or you may need to make an initially large plot first and then go into paint/photoshop/gimp/etc. and make it smaller.
Use annotate to create the axis marks. This is fairly easy if you know how to use annotate, as you're just writing to the location of the axis (y) and the item (x), and then a bit below that for the text. This will make it very easy to make a total garbage plot, but it will likely work ultimately.
These likely work in both SAS/GRAPH and ODS GRAPHICS, and I can't test either as you don't post any code or simulated data to test with, but I think both approaches have some merit (as does the approach of "don't do this", but you've thought that through).

Aligning Multiple Charts in Flex Charting

I have multiple line charts in Flex Charting (3.x). The charts (and number of charts) are being dynamically generated, and are either of "type A" or "type B." The type of data on the Y-axis is different for type A then it is for type B. The x-axis is time.
Each chart is placed in its own VBox (with a few other things) that make up a larger canvas of the Type A or Type B. This VBox is given an absolute X position.
It is very high priority that the different charts line up, so that comparisons (in time) can be made.
What ends up happening is that the vertical axis for some charts takes up more width then others, so the charts are no longer aligned in time.
I have tried playing the VerticalAxisRenderers/AxisRenderer width, but that had no effect.
Any advice would be greatly appreciated.
You can try to set the same gutter left for the both charts. That might help. I had a similar issues, but haven't figured a better answer yet.
I am doing the same thing. If you can use the same HorizontalAxis using a DateTime axis it works great.. you just need to parse the data into an appropriate dateTime.
But, if like me, you need to chart the Time and a parsing the Time values into datetime then provides gaps in data... so far, I have not found an answer, because I am using a Horizontal Axis - Category Axis, but I will try switching that to a Numeric Axis and let you know what I come up with. if anything...
You need to make sure the component uses the same width, height, padding and gutter settings.
For the gutter, which solves what you described, you can find the right info and sample code here:
http://livedocs.adobe.com/flex/3/html/help.html?content=charts_formatting_03.html

Resources