xnx / lineticks Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
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).
Here is the result of dragging from one monitor to another... note that the ticks extend through the curve now...
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.
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
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.