Code Monkey home page Code Monkey logo

lineticks's People

Contributors

xnx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lineticks's Issues

Incorrect transforms with constrained_layout=True

Something is wrong with the transforms when using features like constrained_layout. For a non-working example, try changing the following in ticked_sine.py:

fig, ax = plt.subplots(constrained_layout=True)

The ticks revert to the correct location when the image is resized, but I originally stumbled on this using inline images with matplotlib where there is no interaction.

I also noticed strange behaviour with this when moving the resulting window from one screen to another where things snap back into place but not quite properly (see attached).

image

Here is the result of dragging from one monitor to another... note that the ticks extend through the curve now...

image

Add tick labels to ternary suface plot

Hello,

I'm writing a piece of code to visualize a ternary surface. The surface and the framework seems ok for me, but no labels for the ticks are available. It seems that lineticks package is suitable for this and I have try to use adapt to the current case with Axes3D. Unfortunately, the linesticks do not work as expectation and I would like to seek some help for you.

Figure 1 is the figure that I would to add some ticks and label.
figure_1

I would like to provide the source code for your convenience.

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.tri as mtri
from lineticks import LineTicks

def frame(ax, zlims):
    x = np.linspace(0, 1.0, 20)
    y = x*0.0
    ax.plot(x*0.0, y*0.0, color="blue", zs=np.linspace(zlims[0], zlims[1], 20))
    ax.plot(0.5*(y + 1.0), (y+1.0)*0.5*np.sqrt(3.0), color="blue", zs=np.linspace(zlims[0], zlims[1], 20))
    ax.plot(x*0.0 + 1.0, y*0.0, color="blue", zs=np.linspace(zlims[0], zlims[1], 20))
    # line - 1
    x = np.linspace(0, 0.5, 20)
    y = np.sqrt(3)*x
    line1, = ax.plot(x, y, color="blue")
    ax.plot(x, y, zs=np.max(z), color="blue")
    major_ticks = LineTicks(line1, range(20), 20,lw=1,color='r', direction=-1)

    # line - 2
    x = np.linspace(0.5, 1.0, 20)
    y = -np.sqrt(3)*x + np.sqrt(3)
    ax.plot(x, y, color="blue")
    ax.plot(x, y, zs=np.max(z), color="blue")

    # line - 1
    x = np.linspace(0, 1.0, 20)
    y = x*0.0
    ax.plot(x, y, color="blue")
    ax.plot(x, y, zs=np.max(z), color="blue")
    return ax

x = []
y = []
for x1 in np.arange(0, 1, 0.05).tolist():
    for x2 in np.arange(0, 1.0 - x1, 0.05).tolist():
        x.append(x1 + 0.5*x2)
        y.append(x2*0.5*np.sqrt(3.0))

z = np.array(x)**2 + np.array(y)**2

# Triangulate parameter space to determine the triangles
tri = mtri.Triangulation(x, y)

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')

# The triangles in parameter space determine which x, y, z points are
# connected by an edge
ax.plot_trisurf(x, y, z, triangles=tri.triangles, cmap=plt.cm.Spectral)
ax.set_axis_off()

n = 10
dr = 2.0/n
sqrt3 = np.sqrt(3.0)

ax = frame(ax, [np.min(z), np.max(z)])

plt.show()

Best wishes!

Jing

Ticks not shown in saved figure

When doing plt.show(), ticks along the line are displayed, but when saving the figure using plt.savefig() or fig.savefig(), the ticks are not displayed in the saved image. The code in which I get this bug is quite extensive and the problem is rather simple, so I have not posted any code here. If it is really necessary, I can try to post (simpler) code that will reproduce the bug.

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.