Comments (12)
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.
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.
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.
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()
from circlify.
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.
from circlify.
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()
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.
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.
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.
from circlify.
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.
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.
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)
- Circles Not Populating HOT 2
- With some data the number of generated circles is not as expected. HOT 1
- Add option for making equal size leaves HOT 2
- An example in README.md doesn't work: unexpected keyword argument 'with_enclosure' HOT 1
- Labelling with circ.bubbles doesnot match the circles HOT 2
- circlify.bubbles typo HOT 3
- How to set colors of circles
- Recommendation and issue HOT 4
- How get real circle.x circle.y corresponding input real radius ,not whose area is proportional to the corresponding input value
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 circlify.