Git Product home page Git Product logo

Comments (12)

rawenlei avatar rawenlei commented on May 18, 2024

update:
l0=circ.circlify(a0,target_enclosure=circ.Circle(0,0,2048/1152-0.1),with_enclosure=True)
2048/1152 is my computer display resolution.i find adjust it can fix some circles.

from circlify.

elmotec avatar elmotec commented on May 18, 2024

Hey @rawenlei,

Thank you for taking the time to bring up this issue.

I am fixing the issue now. It should work in the next release and setting the target_enclosure with Circle(0, 0, 2048/1152) is just a happy coincidence that partially works around the problem.

from circlify.

elmotec avatar elmotec commented on May 18, 2024

I believe the issue is fixed by f68f69d. Could you give 0.9.2 a try when you get a chance and let me know if that's not the case?

from circlify.

elmotec avatar elmotec commented on May 18, 2024

Here is what I am getting now with this code:

def drawMutliCircle():
    a0=[0.8,0.2,0.1,0.05,0.05]
    a1=[0.3,0.2,0.2,0.1]
    a2=[0.1,0.05,0.05]
    a3=[0.05,0.04,0.01]
    l0=circ.circlify(a0,with_enclosure=True)
    l1=circ.circlify(a1,target_enclosure=circ.Circle(*l0[0]),with_enclosure=True)
    l2=circ.circlify(a2,target_enclosure=circ.Circle(*l0[1]),with_enclosure=True)
    l3=circ.circlify(a3,target_enclosure=circ.Circle(*l0[2]),with_enclosure=True)
    fig, ax = plt.subplots(figsize=(6,6))
    l=l0+l1+l2+l3
    colors = [plt.cm.Dark2(i / len(l)) for i in range(len(l))]
    for j in l:
        c=plt.Circle((j[0],j[1]),j[2],alpha=0.3,color=colors[l.index(j)-1])
        ax.add_patch(c)
    ax.plot()
    plt.show()

rawenlei

from circlify.

rawenlei avatar rawenlei commented on May 18, 2024

Hey @elmotec ,at first thank you very much!'
with the help of your circlify package, i can easily show the data visualization of circle packing by python.
please allow me to introduce the 'circlify' package which has the advantage of quick response and small footprint to others programmer.
the following is the display of circle packing with three-levels deep via your 'circlify' package.

image

from circlify.

rraadd88 avatar rraadd88 commented on May 18, 2024

Here is what I am getting now with this code:

def drawMutliCircle():
    a0=[0.8,0.2,0.1,0.05,0.05]
    a1=[0.3,0.2,0.2,0.1]
    a2=[0.1,0.05,0.05]
    a3=[0.05,0.04,0.01]
    l0=circ.circlify(a0,with_enclosure=True)
    l1=circ.circlify(a1,target_enclosure=circ.Circle(*l0[0]),with_enclosure=True)
    l2=circ.circlify(a2,target_enclosure=circ.Circle(*l0[1]),with_enclosure=True)
    l3=circ.circlify(a3,target_enclosure=circ.Circle(*l0[2]),with_enclosure=True)
    fig, ax = plt.subplots(figsize=(6,6))
    l=l0+l1+l2+l3
    colors = [plt.cm.Dark2(i / len(l)) for i in range(len(l))]
    for j in l:
        c=plt.Circle((j[0],j[1]),j[2],alpha=0.3,color=colors[l.index(j)-1])
        ax.add_patch(c)
    ax.plot()
    plt.show()

rawenlei

Hi, @elmotec, its a great package. Using it, I would like to make a similar plot. However, in the latest version 0.10.0,
I got this error

TypeError: circlify() got an unexpected keyword argument 'with_enclosure'

The input parameters of circ are

circ.circlify(data, target_enclosure=None, show_enclosure=False, datum_field='datum', id_field='id', children_field='children')

How could I make this plot in the latest version, or should I down-grade the package to earlier version. Please let me know.

from circlify.

elmotec avatar elmotec commented on May 18, 2024

Did you try to use show_enclosure=True instead of with_enclosure=True? I believe I changed the parameter name in version 0.10.

from circlify.

abubelinha avatar abubelinha commented on May 18, 2024

I tried to run the above pieces of code and got indeed this error:
NameError: name 'plt' is not defined

I figure out I should add this at the top:

import matplotlib.pyplot as plt
import circlify as circ

But now when running the code I get:

c=plt.Circle((j[0],j[1]),j[2],alpha=0.3,color=colors[l.index(j)-1])
TypeError: 'Circle' object is not subscriptable

Could anyone tell me what I am doing wrong?

Windows 7
Python 3.8
circlify 0.15.0
matplotlib 3.6.3 

Thanks !!

from circlify.

rawenlei avatar rawenlei commented on May 18, 2024

from circlify.

abubelinha avatar abubelinha commented on May 18, 2024

Thanks @rawenlei
I edited my question and updated the code to import matplotlib and circlify.
But a new error message appears a few lines below:

c=plt.Circle((j[0],j[1]),j[2],alpha=0.3,color=colors[l.index(j)-1])
TypeError: 'Circle' object is not subscriptable

from circlify.

elmotec avatar elmotec commented on May 18, 2024

Thanks @rawenlei for the hand. @abubelinha, could you try this?

import circlify as circ
import matplotlib.pyplot as plt

def drawMutliCircle():
    a0=[0.8,0.2,0.1,0.05,0.05]
    a1=[0.3,0.2,0.2,0.1]
    a2=[0.1,0.05,0.05]
    a3=[0.05,0.04,0.01]
    l0=circ.circlify(a0,with_enclosure=True)
    l1=circ.circlify(a1,target_enclosure=circ.Circle(*l0[0]),with_enclosure=True)
    l2=circ.circlify(a2,target_enclosure=circ.Circle(*l0[1]),with_enclosure=True)
    l3=circ.circlify(a3,target_enclosure=circ.Circle(*l0[2]),with_enclosure=True)
    fig, ax = plt.subplots(figsize=(6,6))
    l=l0+l1+l2+l3
    colors = [plt.cm.Dark2(i / len(l)) for i in range(len(l))]
    for j in l:
        # Circle is not subscriptable via j[0], j[1], j[2], one must use j.x, j.y, and j.r.
        c=plt.Circle((j.x,j.y),j.r, alpha=0.3,color=colors[l.index(j)-1])
        ax.add_patch(c)
    ax.plot()
    plt.show()


if __name__ == "__main__":
    drawMutliCircle()

If it still doesn't work, please check out how it's done in the tests. Also note that with_enclosure is now show_enclosure in later versions.

from circlify.

elmotec avatar elmotec commented on May 18, 2024

Locking this thread because it has moved quite far from the original issue. Please open a new issue if need be.

from circlify.

Related Issues (10)

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.