How to adjust the width of heatmap columns plotted using seaborn - heatmap

I am plotting a heatmap using seaborn and I spent the last day or so trying to adjust the width of the columns because currently they are very wide. From my own search I was to find ways to adjust the size of the heatmap, or the line separating the columns but not the columns themselves. Is this doable using seaborn or should I use another tool?
This is a simple command that I am using:
sns.heatmap(mydata, cmap='Reds')
Thanks!

So after spending more time on this I realized that I could do this easily using pheatmap. You will need to use "cellwidth" parameter to control the width. So for example, pheatmap(mydata, cellwidth = 100). This question was asked for pheatmap here [link] reduce width of columns on a heatmap.2 plot before, but I initially wanted to use seaborn to generate the heatmap. I am still interested to know whether seaborn has a way to control the width.

Related

How to align x-axis scale on two concatenated graphs in Vega Lite

I have a chart composed with vconcat and layer. The layered plot is one of the blocks in the vertical concatenation, it plots two different datasets. There are two more blocks in the vconcat: one that has a different (third) dataset, and another that is a smaller version of one of the layers (used for brushing / zoom). The x scales of all the charts follow the selection via brush signal; the bottom chart sets the signal value via user interaction.
I would like to align the x-axes on all the vconcat chunks. The dataset of the mis-aligned one does not cover as much as the timeseries line (it starts and ends around where the vertical dashed lines are).
When zooming / brushing with the bottom chart, the axes align. When the chart first loads, each x-axis covers the extent of the matching dataset. I'd like the axes to cover the largest extent of all the layers / concat blocks.
I've tried using the resolve config, "shared" vs "independent" etc, with no success.
Not really an answer, but a hack to get the desired result. An accepted answer should be a vega-lite config solution.
I modified the mis-matched dataset to have the same first and last timestamp, which causes the scales to naturally align.

SSRS Combination Pie Chart

I have created a combination chart in excel which I am attempting to replicate within SSRS.
The chart shows three versions of 'success' plus the percentage 'failed'. (Please see image for more detail)
For one of the segments, i.e. success v2, I would like to then break this data down by how long it took to achieve success, as a percentage.
I've attempted changing my chart type a few times within SSRS and exploring the chart 'General Custom Attributes' however I haven't been able to get very far with figuring out how to link two pie/donut charts...your help would be invaluable!
Thanks
Charlotte
Welcome to SO!
This isn't really an answer but a list of things to look at/consider and too long to fit in a comment.
You need to look at the Chart Series properties, in particular the Custom Attributes related to 'Collected...'
This allows you to explode a section but as far as I know it only allows you to use values or a % lower than a specified threshold, not a particular section as you want. This migh work if the section you want to explode out is always the smallest but I guess you cannot guarantee that.
You might be able to get round this by adding another column to your dataset that always shows a high number for 'failure' and 'success x1' and a small number for 'success x2' but i'm not sure if you can define which field to explode on and visualise a different field, otherwise your main pie would look incorrect.
Alternatively you could just show two charts.

SSRS Charts: solution for better assignment of colors to the legend

If you have a line chart in SSRS with many lines, it is nearly impossible to identify which line belongs to which item in the legend, as the colors are nearly the same. Is there a better solution?
bad example of line chart legend
Some suggestions that may help:
Group some of the values into an Other group. It looks like you have
some values that come and go, or don't run for the full timeframe of the
report, lumping these into an Other group will mean less legend items.
Move the legend to the bottom of the chart. This can sometimes make
the legend easier to see; this is not a good option when have a lot
more legend items than what you have now.
Use more than one chart; one chart for each line is possible. This
may be a good option for you. Use more than one chart, and only
display certain values in each. Perhaps you have some natural
grouping in the data that isn’t obvious from what you have provided
in the question. If you do, use that to separate the values into
different charts.
Use a different color theme. The theme you are using now would leave
any color-blind person wondering what was in the chart at all.
Make the chart larger. You just never know, this may work.
Use a column chart rather than a line chart. The bars are wider, and
can be easier to see. Plus, with the way your values come and go, it
may be a better way to visualize the data.
Limit the timeframe of the data being displayed. Having less data may
make this look better, but that may defeat the purpose of the report.
Still, it’s an option.
Good luck.
All good ideas by R Richards. I often end up with charts looking like yours. The first thing I do is ask. Is this of any use to the end user, if not I'll try to rationalise the chart. Some of the ideas in the earlier answer are things I try but also you can try the following without reducing the amount of data in the chart.
Simply make the lines thicker, it's much easier to identify the colours with thicker lines.
Add tooltips to the data points so that the user can hover over the
lines and get info about the line and/or point.
Use a custom pallet, the default palette does not have many colours in (7 I think), so colours are repeated. Creating a custom palette with more colours will make it easier to identify each line. It also means, if you can ensure the order of series in your data that you can you produce consistent charts were a colour always represents a specific business object.
If you have breaks in the data, change the chart to use an average
to give you a continuous line. I think your x axis has to be set as
a time type for this to work, I can't remember off the top of my
head.
Here's a before and after the first two ideas were applied to a sample chart I built.
If you think you need to reduce the data, group line with smaller values together and then add a drill down chart to show these lines.

Ordering bar chart in python by decreasing value

I've created a stacked bar chart using plotly and would like to order the categorical variables on the x-axis according to decreasing values, based on their corresponding total y value. What is the best way to do this? Thanks in advance!
Hard without seeing your code, so I'll presume you're using pandas with plotly.
If so, it would be:
df['Your_X_Series'].sort_values(ascending=False, inplace=True)
And then plot the series.

OCR match frame´s position to field in credit card

I am developing an OCR to detect credit card.
After scanning the image I get a list of words with it´s positions.
Any tips/suggestions about the best approach to detect which words correspond to each field of credit card (number, date, name)?
For example:
position = 96.00 491.00
text = CARDHOLDER
Thanks in advance
Your first problem is that most OCRs are not optimised for small amounts of text that take up most of the "page" (or card image, in your case) in spatially separated chunks. They expect lines, or pages of text from a scanned book or a newspaper. So straight away they're not likely to do that well at analysing the image.
Because the font is fairly uniform they'll likely recognise the characters well, but the layout will confuse the page segmentation algorithm and so the text you get out might not be in the right order. For example, the "1234" of the card number and the smaller "1234" below it constitute a single column of text, likewise the second two sets of four numbers and the expiration date.
For specialized cases where you know the layout in advance you really want to develop your own page segmentation algorithm to break up the image into zones, e.g. card number, card holder name, start and expiration dates. This shouldn't be too hard because I think the location of these components are standardised on credit cards. Assuming good preprocessing and binarization you could basically do a horizontal histogram and split the image at the troughs.
Then extract each zone as a separate image containing just one line of text and feed it to the OCR.
Alternately (the quick and dirty approach)
Instruct the OCR that what you want to recognise consists of a single column (i.e. prevent it from trying to figure out the page layout itself). You can do this with Tesseract using the -psm (page segmentation mode) parameter set to, probably, 6 (but try and see what gives you the best results)
Make Tesseract output hOCR format, which you can set in the configfile. hOCR format includes the bounding boxes of the lines that get output relative to the whole image.
write an algorithm that compares the bounding boxes in the hOCR to where you know each card component should be (looking for some percentage of overlap, it won't match exactly for obvious reasons.)
In addition to the good tips provided by Mikesname, you can greatly improve the recognition result regardless of which OCR engine you use if you use image processing to convert the image to bitonal (pure black and white), such as the attached copy of your image.