Coder Social home page Coder Social logo

Comments (5)

Phlya avatar Phlya commented on July 19, 2024 1

You need to define new graph variable before adding texts to it. And your try:-except: constructs hid that adjustment didn't work at all and actually raised an error.

labels = ['test1', 'test2', 'test3', 'test4', 'test5', 'test6', 'test7', 'test8', 'test9', 'test10', 'test11', 'test12', 'test13', 'test14', 'test15']

x = [4.00, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50]
y = [2.50, 2.55, 2.60, 2.65, 2.70, 2.75, 2.80, 2.85, 2.90, 2.95, 3.00, 3.50, 3.35, 3.25, 3.50]

ax1 = plt.subplot2grid((2,2), (0,0), rowspan=1, colspan=1)
ax2 = plt.subplot2grid((2,2), (0,1), rowspan=1, colspan=1)
ax3 = plt.subplot2grid((2,2), (1,0), rowspan=1, colspan=1)
ax4 = plt.subplot2grid((2,2), (1,1), rowspan=1, colspan=1)

ax1.scatter(x, y, c='b', alpha=1, vmin=0, vmax=4, zorder=2)
ax2.scatter(x, y, c='b', alpha=1, vmin=0, vmax=4, zorder=2)
ax3.scatter(x, y, c='b', alpha=1, vmin=0, vmax=4, zorder=2)
ax4.scatter(x, y, c='b', alpha=1, vmin=0, vmax=4, zorder=2)

ax1.set_xlim(0,3)
ax2.set_xlim(3,4)
ax3.set_xlim(0,3)
ax4.set_xlim(3,4)

ax1.set_ylim(3,4)
ax2.set_ylim(3,4)
ax3.set_ylim(0,3)
ax4.set_ylim(0,3)

ax1.plot([3,3],[0,4], linewidth=3, color='black')
ax1.plot([0,4],[3,3], linewidth=3, color='black')
ax2.plot([3,3],[0,4], linewidth=3, color='black')
ax2.plot([0,4],[3,3], linewidth=3, color='black')
ax3.plot([3,3],[0,4], linewidth=3, color='black')
ax3.plot([0,4],[3,3], linewidth=3, color='black')
ax4.plot([3,3],[0,4], linewidth=3, color='black')
ax4.plot([0,4],[3,3], linewidth=3, color='black')

graph=[]

for i, txt in enumerate(labels):
    if(x[i]>=0 and x[i]<=3 and y[i]<=4 and y[i]>3):
        graph.append(ax1.text(x[i], y[i], txt, color='purple', size=8, bbox=dict(boxstyle="square", fc="w", pad=0.2)))
adjust_text(graph, ax=ax1, arrowprops=dict(arrowstyle="->"))

graph = []
for i, txt in enumerate(labels):
    if(x[i]<=4 and x[i]>3 and y[i]<=4 and y[i]>3):
        graph.append(ax2.text(x[i], y[i], txt, color='purple', size=8, bbox=dict(boxstyle="square", fc="w", pad=0.2)))
adjust_text(graph, ax=ax2, arrowprops=dict(arrowstyle="->"))

graph = []
for i, txt in enumerate(labels):
    if(x[i]>=0 and x[i]<=3 and y[i]>=0 and y[i]<=3):
        graph.append(ax3.text(df.x[i], df.y[i], txt, color='purple',size=8,bbox=dict(boxstyle="square", fc="w", pad=0.2)))
adjust_text(graph, ax=ax3, arrowprops=dict(arrowstyle="->"))

graph = []
for i, txt in enumerate(labels):
    if(x[i]<=4 and x[i]>3 and y[i]>=0 and y[i]<=3):
        graph.append(ax4.text(x[i], y[i], txt, color='purple', size=8, bbox=dict(boxstyle="square", fc="w", pad=0.2)))
adjust_text(graph, ax=ax4, arrowprops=dict(arrowstyle="->"))

plt.show()

image

from adjusttext.

Phlya avatar Phlya commented on July 19, 2024

Can you please make a minimal reproducible example?

from adjusttext.

wwwwwww123 avatar wwwwwww123 commented on July 19, 2024

Example of the graph is attached here.
scatterplot

from adjusttext.

Phlya avatar Phlya commented on July 19, 2024

With code, please

from adjusttext.

wwwwwww123 avatar wwwwwww123 commented on July 19, 2024

.py Code here:
scatter.txt

Sorry accidentally closed the issue >.<

from adjusttext.

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.