Graph Data Overlaps Axes labels When Scrolling - android-graphview

When enabling scrolling and/or scaling, the data on the graph overlaps the y-axes of the graph. The y-axis labels can be covered and the data can spill out the right hand side too. Is there a method to fix this?
Code:
// min and max are the first and last X-values of the data
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMinX(min);
graph.getViewport().setMaxX(max);
graph.getViewport().setScalable(true);
graph.getGridLabelRenderer().setNumHorizontalLabels(3);
graph.getGridLabelRenderer().setHumanRounding(false);
Edit: This phenomenon also happens when enabling scaling in the Y axis, only it overlaps the X-axis instead.

Related

Place MATLAB legend such that it does not overlap on the plot

I am generating multiple plots of different datasets in succession using MATLAB. I would like the legend positions to be such that they don't overlap on the plotted lines and it would be ideal if this placement could be done automatically.
I am aware of setting the 'Location' to 'best' to achieve this but the placement of the legend tends to be awkward when 'best' is used (below). Also, I would like the legend to be inside the plot. I also came across a way to make the legend transparent (here) so that it does not render the plotted data invisible, but explicitly placing the legend elsewhere is what I am looking for.
Is there a way to place the legend at the extremes of the image ('NorthWest', 'SouthWest' etc) automatically such that it does not overlap on the plotted data (apart from the methods suggested above)?
So, you have tried using Location instead of Position? For example:
x =1:100;
y = x.^2;
lgd = legend('y = x.^2');
set(lgd,'Location','best')
and you are getting odd results correct? A quick way of solving this would be to still use Location, with best, and extract the coordinates:
lgd.Position
You should get something like this:
ans =
0.7734 0.3037 0.1082 0.0200
which maps to:
[left bottom width height]
You will need to focus on left and bottom. These two values, left and bottom, specify the distance from the lower left corner of the figure to the lower left corner of the legend, and they are analogous to the grid frame you are using.
Then, depending on the size of the frame (I would suggest you use axis([XMIN XMAX YMIN YMAX]) for this, if possible), you can pinpoint the position of the legend within the grid. What you can do next, is check if and which of your graphs in the plot cross paths with the legend (maybe define a relative distance function based on some distance threshold) and if they do, then randomly reposition the legend (i.e. change the values of left and bottom) and repeat until your conditions are met.
If this still troubles you I can write a short snippet. Finally, know that you can always opt for placing the legend on the outside:
set(lgd,'Location','BestOutside')

Tableau Control Chart - Attribute measure incorrect

All
I have a control chart, with on the X-axis a time period, and the Y-axis the value of the measure (I'd like to plot all the points in a control chart).
However, I have 2 different values as a measure, which have the exact same date (up to a second match) but different measure values.
When I plot this on a control chart, instead of having 2 points in the control chart with value 500 and 550 for example - it gives me one point with a value of about 200.
It also gives a notification that there is a NULL value in this axis, which points to the X-axis where 2 records have the exact same date.
Any idea what I can do to make this correct - or make tableau draw the measure points correctly?
Thanks in advance!
It's difficult to answer without seeing more detail about your problem, but this sounds like a good candidate for a blended axis. (multiple measures sharing a single axis)
The easiest way to do this is to put your (probably continuous) datetime field on the row axis and one of your measures on the row axis to see one of then control plots. Then drag the second measure to the Y-axis until you see a little translucent two bar icon to indicate that you are adding a second measure to that axis, at which point you can release the pointer and you should see a two plots on the same axis.
If the scales for the two measures are radically different, you can instead drag the second measure to the right side instead to get a dual axis.

CorePlot polar plot

It became apparent that I needed to attempt to modify CorePlot code to allow me to plot Polar/Radar plots, due to heavy memory usage trying to plot circles/spokes as ScatterPlots.
I realised I could continue to use CPTScatterPlot for the actual polar data, however somehow I needed to modify the drawGridLinesInContext, such that instead of straight lines at each location, CPTXCoordinate would draw the circular line, CPTYCoordinate would be ignored, and CPTZCoordinate would draw the spokes.
I had to create new classes based on their XY siblings viz CPTPolarGraph, CPTPolarPlotSpace, CPTPolarAxisSet, CPTPolarAxis. The new code continues to use X and Y axis to plot those axes, however a Z axis was introduced to manage the spokes.
Now I seem to have cracked this, however if I scroll up and down, the circles continue to pass through the X and Y axis ticks, as they should do, but when I scroll left and right, the circles get redrawn and no longer sit on the ticks.
I obviously got some more debugging to do here, but was hoping for some pointers from the CorePlot crew, as to what might be happening
.
I can zip my modified version of CorePlot_1.1, including a example polar scatter plot, and forward if needs be.
The positioning of the centreViewPoint tracks precisely, as the spokes are always generated from the same point, wherever the centre is in the plotArea. The rings are also always generated from the same centre.
It seems to me that somehow, the diameters of the rings when I scroll left right get changed from the first plot presentation, yet when I scrolled Up-down they don't. Notice that when the plot is scrolled to left edge or right edge the major rings are line up on the major ticks again, as are the minor.
I tried reversing the code such that only the CPTCoordinateY get plotted, and I see the same effect, except scrolling up-down exhibits the changing in ring diameter size.
Now perhaps CGPoint startViewPoint = [thePlotSpace plotAreaViewPointForPlotPoint:startPlotPoint]; which establishes the diameter of a ring from its x-coordinate, is not returning correctly. Although perhaps also the locations set are changing, but why should they if no zooming has been done.
I'm kind of struggling here, as when I walk through the code the locations don't appear to change.
This is likely a pixel alignment issue. The tick drawing code aligns the tick marks with the pixel grid but the new axis drawing does not. Look at CPTAlignRectToUserSpace() and the other alignment functions in CPTUtilities.h.
Edit:
You also may need a custom setter method for the zRange in the plot space. Make it similar to the xRange and yRange setters. The notifications fired by these methods are important—they force other parts of the graph to redraw when the plot space changes.

Matlab function surf axes going from high to low I want low to high?

Last question on this I swear.
Right now the plot of surf has the dates going from newest (i.e today) at the left hand side to oldest on the right hand side. I would like it to be the other wat round but keep everything else the same.
Is there a quick way to do this? Without having to reorganise the input data?
You can simply revert the direction of the axis. If it's the x-axis, you write
set(gca,'XDir','reverse')
gca grabs the handle to the currently active axes, so make sure that the surface is on the active figure, or store the axis handle somewhere and pass it instead as first argument to set.
Just replace the X in XDir if you want to do it for a different axis.
This can be set using axis properties:
Direction of increasing values. A mode controlling the direction of increasing axis values. Axes form a right-hand coordinate system. By default:
x-axis values increase from left to right. To reverse the direction of increasing x values, set this property to reverse.
set(gca,'XDir','reverse')
y-axis values increase from bottom to top (2-D view) or front to back (3-D view). To reverse the direction of increasing y values, set this property to reverse.
set(gca,'YDir','reverse')
z-axis values increase pointing out of the screen (2-D view) or from bottom to top (3-D view). To reverse the direction of increasing z values, set this property to reverse.
set(gca,'ZDir','reverse')

Core Plot - get data to fill up x axis screen space

My Core Plot is almost finished up but I've noticed an unusual thing I need to change before calling it done. The x axis is scaled properly along the bottom, and the left and right edges indicate the range that I've set. The data, however, is all crushed together on the left side, almost as if the y values are not corresponding to their proper x values.
This image should demonstrate what I mean. You'll notice that the dates run along the bottom, but the actual values don't go past the 6/3/11 mark. They should be all the way to the right.
Link to image
Check the values returned by your datasource. Make sure the x-values are calculated from the same starting date and intervals that you used for the x-axis range and labels.