Giter Club home page Giter Club logo

Comments (1)

bmondal94 avatar bmondal94 commented on July 18, 2024 1

Answer: The first color is missing in version 1.0.8 because of the addition of one additional function call in TernaryAxesSubplot class, ( Add functions for setting a ternary specific background color ). It calls self.set_background_color(), which intern calls background_color() from heatmapping.py (Please check out the __init__ in TernaryAxesSubplot). This background_color() function essentially creates the triangular region filled with 'whitesmoke' color, which you see in the background of your 2nd figure.
Now, let's go back to your code.

fig, tax = ternary.figure(scale=1) 
tax.scatter([(1.1/3, 0.9/3, 1/3)], label="first")
tax.scatter([(0.9/3, 1.1/3, 1/3)], label="second")
tax.legend()
tax.set_title(f"python-ternary {ternary.__version__}")
tax.show()

Apparently, it looks like you created the tax in line 1 and drew scatter after that. So, the first scatter call should be the first time something is drawn on your axis. But note, the ternary.figure() already called the background_color() function. So, you already drew the first drawing on your axis, and the tax.scatter() call is actually the 2nd time you are drawing something on the axis. That's why the 1st color is missing in tax.scatter().
You can easily check this if you comment out the self.set_background_color() call in __init__ in TernaryAxesSubplot class.

Solution: You just have to restart your color cycle.

import ternary
import matplotlib.pyplot as plt

fig, tax = ternary.figure(scale=1)
plt.gca().set_prop_cycle(None)  # restarts the color cycle
tax.scatter([(1.1/3, 0.9/3, 1/3)], label="first")
tax.scatter([(0.9/3, 1.1/3, 1/3)], label="second")
tax.legend()
tax.set_title(f"python-ternary {ternary.__version__}")
tax.show()

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.