Add a "Plus Sign (+)" to a histogram axis using truncated data - histogram

I have some data with a long tail, which has been truncated for a histogram. I would like to add a simple "+" sign to the final value of the x-axis on the histogram. Below is an example showing the setup.
sysuse auto
gen price_graph = price
replace price_graph =10000 if price_graph>10000
hist price_graph, start(0) width(1000)
Below is the result of the above code, with the "+" sign drawn in and highlighted where I would like to put it:
I could also see scenarios when data would be truncated from the left as well, so a robust solution would be easily applicable to both scenarios.

hist price_graph, start(0) width(1000) xla(0(2000)8000 10000 "10000+")
You spell out that you want specific text as a specific axis label. You then (optionally) indicate what other labels you want.

Related

Vertical Spacing in ESC/POS

I'm printing an adhesive label (6x5cm) with a printer model 3nStar RPT006.
In the adhesive I am printing a title, QR code and the QR code in text
something like this
My Title
▄
qr code
Using this class as reference, I'm doing something like this:
initialize(),
setJustification(Printer.JUSTIFY_CENTER),
'My Title',
feed(),
qr(qrText),
feed(),
qrText,
feed(2),
cut(Printer.CUT_FULL, 1),
My problem is: I don't know how to control the vertical size, or how to set the height of the paper. Between each label I have a gap of 3mm.
So my question is, how should I handle the vertical spacing/height?
Currently I very close to get a perfect label, but seems like the printed label is some millimeters shorter and each time I print a label, it miss a little bit more, so there is a time where I start to cut the adhesive part and not the gap
I'm not sure if it's possible in your environment, but there are three options.
Prepare blank image data with the required number of vertical dots and print it(graphics(EscposImage $image, $size)) instead of the line feed code.
Use setLineSpacing($height) to change the height of one line only for the required part and start a new line. Then return to the original size.
Make your own customization by adding the function to feed the paper in dot units to the library for printing.
ESC J

how to show YOY metric values as text in a tableau viz

please click here for the image
2 questions to the Tableau Sanseis:
The given percentages/numbers in the attachment (shown by parentheses), all belong to the YOY variance and are meant to be displayed in front of the orange (2021) bars
a) Both the numbers/percentages are not showing in one line and current display gives the impression to a user that %ages belong to the blue bars and number to the orange colored bars.
- How to show both in front of orange bars ?
b) Beats me as to why some of the category bars (highlighted with red arrows) don't display any value (no %ages or numbers)
Thanks in advance
Probably "between" your two measure there's some CR, so you see one up and the other down, causing to display just some values and not all.
Something like this:
Go into the Text Mark of your worksheet, and try to dispay your values in just one line with no CR, and you should get something like this:
Sometimes, due to font size and cardinality of your data, some label could be missing just because Tableau tries to optimize the rendering, but you can also check the last option of the Label Mark selecting "Allow Labels to overlap other marks".

How to remove non-periodic lines from binary image

Example Image
I want to remove the lines (shown in RED color) as they are out of order. Lines shown in black color are repeating at same period (approximately). Period is not known beforehand. Is there any way of deleting non-periodic lines( shown in red color) automatically?
NOTE: Image is binary ( back & while).. lines shown in red color only for illustration.
Of course there is any way. There is almost always some way to do something.
Infortunately you have not provided any particular problem. The entire thing is too broad to be answered here.
To help you getting started: (I highly recommend you start with pen, paper and your brain)
Detect the lines -> google or think, there are many standard ways to detect lines in an image. if you don't have noise in your binary image its trivial.
find any aequidistant sets -> think
delete the rest -> think ( you know what is good so everything else has to go away)
I assume, your lines are (almost) vertical.
The following should work
turn the image to a column sum histogram
try a Fourier transformation on the signal (potentially padding the image appropriately)
pick the maximum/peak from the Fourier spectrum as your base period
If you need the lines rather than the position of the lines, generate a mask with lines at appropriate intervals (as determined by your analysis before) and apply to the image.

OpenCV: Generating points from image after thinning

I've ran in to an issue concerning generating floating point coordinates from an image.
The original problem is as follows:
the input image is handwritten text. From this I want to generate a set of points (just x,y coordinates) that make up the individual characters.
At first I used findContours in order to generate the points. Since this finds the edges of the characters it first needs to be ran through a thinning algorithm, since I'm not interested in the shape of the characters, only the lines or as in this case, points.
Input:
thinning:
So, I run my input through the thinning algorithm and all is fine, output looks good. Running findContours on this however does not work out so good, it skips a lot of stuff and I end up with something unusable.
The second idea was to generate bounding boxes (with findContours), use these bounding boxes to grab the characters from the thinning process and grab all none-white pixel indices as "points" and offset them by the bounding box position. This generates even worse output, and seems like a bad method.
Horrible code for this:
Mat temp = new Mat(edges, bb);
byte roi_buff[] = new byte[(int) (temp.total() * temp.channels())];
temp.get(0, 0, roi_buff);
int COLS = temp.cols();
List<Point> preArrayList = new ArrayList<Point>();
for(int i = 0; i < roi_buff.length; i++)
{
if(roi_buff[i] != 0)
{
Point tempP = bb.tl();
tempP.x += i%COLS;
tempP.y += i/COLS;
preArrayList.add(tempP);
}
}
Is there any alternatives or am I overlooking something?
UPDATE:
I overlooked the fact that I need the points (pixels) to be ordered. In the method above I simply do scanline approach to grabbing all the pixels. If you look at the 'o' for example, it would grab first the point on the left hand side, then the one on the right hand side. I would need them to be ordered by their neighbouring pixels since I want to draw paths with the points later on (outside of opencv).
Is this possible?
You should look into implementing your own connected components labelling. The concept is very simple: you scan the first line and assign unique labels to each horizontally connected strip of pixels. You basically check for every pixel if it is connected to its left neighbour and assign it either that neighbour's label or a new label. In the second row you do the same, but you also check against the pixels above it. Sometimes you need a label merge: two strips that were not connected in the previous row are joined in the current row. The way to deal with this is either to keep a list of label equivalences or use pointers to labels (so you can easily do a complete label change for an object).
This is basically what findContours does, but if you implement it yourself you have the freedom to go for 8-connectedness and even bridge a single-pixel or two-pixel gap. That way you get "almost-connected components labelling". It looks like you need this for the "w" in your example picture.
Once you have the image labelled this way, you can push all the pixels of a single label to a vector, and order them something like this. Find the top left pixel, push it to a new vector and erase it from the original vector. Now find the pixel in the original vector closest to it, push it to the new vector and erase from the original. Continue until all pixels have been transferred.
It will not be very fast this way, but it should be a start.

How can I make Core Plot to show an x-axis label for each point in time?

Apart from the issue I am trying to fix atm, I would like to know how I can make the x-axis labels to draw wherever there is a point drawn. As you can see on the screenshot there are three points in time. So instead of the label "1/10/54' (yes that is year 54) floating nowhere, I want three labels, one below each point.
(Note the 3 points are only for illustration, needs to be expandable.)
If the spacing between the labels will be irregular like your sample screenshot, you'll want to change the axis labeling policy to CPTAxisLabelingPolicyNone or CPTAxisLabelingPolicyLocationsProvided. Both policies require you to provide the tick locations. The first policy also requires you to make custom labels that don't have to be at the same locations as the tick marks while the second will automatically make labels at each tick location using the standard label formatter.

Resources