Giter Club home page Giter Club logo

Comments (4)

bmondal94 avatar bmondal94 commented on August 17, 2024 1

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.

marcharper avatar marcharper commented on August 17, 2024

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.

ericwhester avatar ericwhester commented on August 17, 2024

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.

ericwhester avatar ericwhester commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.