question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Heatmap content is flipped vertically

See original GitHub issue

Bug Report

Issue: (Bug description goes here) When plotting data in the Heatmap the data is flipped vertically.

Reproducing: (What do others have to do to reproduce the bug?) You can see this even in the plots in the Cookbook Heatmap examples. The “coldest” point should be at (0,0) but it is on the max Y row and the “hottest” point should be on the max Y row but it is on the min Y row in the plot.

It appears this is happening in the “Update” function. The 2D data is flattened into a 1D array. Later in that routine the Rectangle is defined with the upper left corner set at 0,0. I believe the flattened data is then used to populate that Rectangle from that upper left corner down. In playing with this is I added the line of code shown below at the end of the Update function and I get the expected results. I am not sure if there is a more elegant/efficient way to solve this.

// a code sample may improve communication
BmpHeatmap.RotateFlip(RotateFlipType.RotateNoneFlipY);

System Details

  • ScottPlot Version: 4.1.123?
  • Operating System: (Windows 10.)
  • Application Type: (console)
  • .NET Version: (.NET 6.0)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
vtozarkscommented, May 31, 2022

Here is an example OxyPlot I got from a colleague (plot for data at (+/-1, +/-1). In a discussion with a couple engineers in my office several flagged that the other tools are centering each square on the raw data coordinate and raised some concern that the ScotPlott example was effectively building in a (0.5, 0.5) offset that is not present in the raw data. All agreed that if coordinates are shown on the axis then they should align with the raw data to prevent inaccurate conclusions from the plot no matter which way the data is plotted (starting at upper left or lower left).

OxyPlotHeatMap

0reactions
swhardencommented, Jun 2, 2022

Thanks for reaching out @vtozarks! The fix @bclehmann offered in #1866 looks great and I’m merging it in now.

Regarding simpler ways to do this in ScottPlot5, I don’t even think we need to note it in #1028. Now that the heatmap module has been running in the wild for a long time I think we have a better idea than when we started about what parts people find intuitive vs. unintuitive/surprising, and could probably design a new API around the 99% use case, and not worry about breaking changes. The time isn’t quite right to dive into that yet, but I look forward to hopefully working on it soon!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to rotate Seaborn heatmap in python?
You can flip the y-axis using ax.invert_yaxis() : import seaborn as sns import numpy as np np.random.seed(0) sns.set_theme() uniform_data ...
Read more >
Heatmap Axis Labels Printing Vertically? - MATLAB Answers
The heatmap's X labels orientation is dynamically determined based on the number of labels and the axes width. In other words, if you...
Read more >
How to flip heatmap Y axis - MATLAB Answers
I am creating a heatmap based on a table with x and z coordinate and the parameter value for each position. I copy...
Read more >
Heatmap.2 - flip dendrogram so control group appears on ...
I am wanting to flip the dendrogram above my heatmap so that the SC group appears on the left of the heatmap and...
Read more >
Chapter 3 Heatmap Annotations | ComplexHeatmap ...
The direction of the axis can be reversed which is useful when the annotation is put on the left of the heatmap.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found