Comments (11)
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.
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.
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.
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.
Thanks. Feel free to submit a pull request, otherwise I'll fix it within a few days.
from python-ternary.
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.
I just pushed a new release (1.0.5) that contains the fix.
from python-ternary.
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:
from python-ternary.
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.
from python-ternary.
I'll update the examples to indicate this. Thanks for the report!
from python-ternary.
Cool, problem solved. Thanks for the quick reply!
from python-ternary.
Related Issues (20)
- Question on ternary heatmap plot HOT 1
- Can not set the limits of each axis? HOT 1
- Heatmap scale greater than 1 vs less than equal to 1 HOT 4
- 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
- Distance between tick labels (numbers) and axis HOT 1
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.