Comments (4)
Approach-1: Update the source code as mentioned in #191 (comment) .
Approach-2: Calculate the heatmap data with scale 100 but set the tick labels with scale 1.
import random
import numpy as np
'''
Principle: Creating heatmap w.r.t scale=100 but label the ticks with scale=1.
'''
def generate_random_heatmap_data(scale=5):
from ternary.helpers import simplex_iterator
d = dict()
for (i,j,k) in simplex_iterator(scale):
d[(i,j,k)] = random.random()
return d
scale = 100
d = generate_random_heatmap_data(scale)
dd = {tuple(np.array(x[0])/scale): x[1] for x in d.items()}
#------------------------------------------------------------------------------
figure, tax = ternary.figure(scale=scale)
figure.set_size_inches(10, 8)
tax.heatmap(d, style="h")
tax.boundary()
tax.clear_matplotlib_ticks()
tax.get_axes().axis('off')
tax.set_title(f"Heatmap Test: Hexagonal (original scale={tax.get_scale()})")
# ------------- Create tick labels with scale 1 --------------------------
TickLabels = list(np.linspace(0,1,11,dtype=float))
tax.ticks(ticks=TickLabels, multiple=10, tick_formats={'b':'%.1f','l':'%.1f','r':'%.1f'})
from python-ternary.
The existing ternary
heatmap
function isn't intended to work with scale = 1. It assumes that you'll define your own triangulation of the simplex and compute the desired value for each i, j, k combination, much like heatmapf
does if you supply a function that can compute the values. In this case scale controls how many lattice points of the simplex to evaluate, much like the gridsize parameter in matplotlib's hexbin
function (but hexbin
is otherwise more of a histogram).
from python-ternary.
Is there some way that we can at least rescale the axes/axis ticks to go from 0 to 1 while also getting heatmapf to work?
from python-ternary.
Thanks for the tip on adjusting the ticks.
I also found another alternative: use plt.tripcolors with a rescaled version of the points (derived from simplex_iterator) on tax.ax (where tax has scale 1).
from python-ternary.
Related Issues (20)
- Scatter creates equilateral plot HOT 1
- Question on ternary heatmap plot HOT 1
- Can not set the limits of each axis? HOT 1
- Cut off top of triangle? HOT 5
- Problem in making the ternary heatmap if the key interval is not 1. HOT 1
- TernaryAxesSubplot.scatter() skips first default color in version 1.0.8 HOT 1
- How to plot the Ternary Choropleth Map? HOT 3
- Heatmap polygon triangles and gridlines don't meet exactly HOT 4
- Blank Heatmap HOT 6
- Plot Blocking Option
- Custom Axis Directions HOT 2
- Cannot set transparent background HOT 1
- Issues with corner label positions under panning/zooming HOT 4
- change font, and output an equilateral triangle HOT 2
- Can't find a way that works to reduce label overlap. HOT 2
- Update installation metadata
- Remove number
- Text annotations HOT 1
- Add pyproject.toml file for python 3.12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-ternary.