Giter Club home page Giter Club logo

Comments (11)

fedorn avatar fedorn commented on July 17, 2024

I figured that tick_formats="%.1f" argument should be added to tax.ticks to fix the problem. I'm keeping this issue open because example code should be fixed.

from python-ternary.

marcharper avatar marcharper commented on July 17, 2024

This sounds like a change in matplotlib, I don't recall any explicit changes that would have caused this. I'm not opposed to changing the defaults, but this is more of a preference than an issue IMO.

from python-ternary.

fedorn avatar fedorn commented on July 17, 2024

The change is here 4f5dab6#diff-812376a19bf7f47735f8b85a2b0bcc40L261. Look at line 272: s = str(int(tick)). I don't oppose keeping it, but lines 34,35 in examples/color_coded_heatmap.py should be updated accordingly (tick_formats in line 35 should be used instead of round() in line 34).

from python-ternary.

fedorn avatar fedorn commented on July 17, 2024

Here's the diff

diff --git a/examples/color_coded_heatmap.py b/examples/color_coded_heatmap.py
index 3f459de..d24c9b6 100644
--- a/examples/color_coded_heatmap.py
+++ b/examples/color_coded_heatmap.py
@@ -31,9 +31,9 @@ tax.gridlines(multiple=1, linewidth=2,
               right_kwargs={'color':axes_colors['r']},
               alpha=0.7)
 
-ticks = [round(i / float(scale), 1) for i in range(scale+1)]
+ticks = [i / float(scale) for i in range(scale+1)]
 tax.ticks(ticks=ticks, axis='rlb', linewidth=1, clockwise=True,
-          axes_colors=axes_colors, offset=0.03)
+          axes_colors=axes_colors, offset=0.03, tick_formats="%.1f")
 
 tax.clear_matplotlib_ticks()
 

from python-ternary.

marcharper avatar marcharper commented on July 17, 2024

Thanks. Feel free to submit a pull request, otherwise I'll fix it within a few days.

from python-ternary.

chengrunyang avatar chengrunyang commented on July 17, 2024

Hi, has this been fixed? I am still getting ticks like 0,0,0,0,0,0,0,0,0,0,1 instead of 0.0,0.1,0.2,...1.0. The python-ternary version I have installed is 1.0.4.

from python-ternary.

marcharper avatar marcharper commented on July 17, 2024

I just pushed a new release (1.0.5) that contains the fix.

from python-ternary.

chengrunyang avatar chengrunyang commented on July 17, 2024

I upgraded my installation by pip but the problem still seems to occur. An example, which is a slight modification of your demo, is as follows:

import ternary
import random
from matplotlib import pyplot as plt

def random_points(num_points=25, scale=40):
    points = []
    for i in range(num_points):
        x = random.randint(1, scale)
        y = random.randint(0, scale - x)
        z = scale - x - y
        points.append((x, y, z))
    return points

scale=1
fontsize=20
fig, ax = plt.subplots(figsize=(12, 10.4))
plt.axis('off')
tax = ternary.TernaryAxesSubplot(ax=ax, scale=scale)

tax.boundary(linewidth=2.0)
tax.gridlines(multiple=0.1, color="blue")

points = random_points(2, scale=scale)
print(points)
tax.scatter(points, s=100, marker='D', color='green', label="Green Diamonds")

tax.ticks(axis='lbr', linewidth=1, multiple=0.1)
tax.clear_matplotlib_ticks()
tax.show()

This produces the following plot:
image

from python-ternary.

marcharper avatar marcharper commented on July 17, 2024

You have to pass in a formatting argument:
tax.ticks(axis='lbr', linewidth=1, multiple=0.1, tick_formats="%.1f")

I'll consider trying to detect if non-integer tick formats can be inferred from the other arguments.

image

from python-ternary.

marcharper avatar marcharper commented on July 17, 2024

I'll update the examples to indicate this. Thanks for the report!

from python-ternary.

chengrunyang avatar chengrunyang commented on July 17, 2024

Cool, problem solved. Thanks for the quick reply!

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.