How to totally remove x-axis (and y-axis) from the plot and also draw tangent lines at certain points using Python or R-
Tag : python , By : user130518
Date : March 29 2020, 07:55 AM
this will help I have to create a plot that has axes suppressed and tangents drawn at regular intervals as shown in figure presented below. , Using Python, import numpy as np
import matplotlib.pyplot as plt
tau = np.arange(-5, 5, 0.01)
a = 0.4
sigma = a*tau
x = 1/a*np.cosh(sigma)
y = 1/a*np.sinh(sigma)
fig, ax = plt.subplots()
ax.plot(x, y, c='black')
# approximate the curve by a cubic
dxds = np.poly1d(np.polyfit(sigma, x, 3)).deriv()
dyds = np.poly1d(np.polyfit(sigma, y, 3)).deriv()
xs, ys, dxs, dys = [], [], [], []
for s in np.linspace(-1, 1, 5):
# evaluate the derivative at s
dx = np.polyval(dxds, s)
dy = np.polyval(dyds, s)
# record the x, y location and dx, dy tangent vector associated with s
xi = 1/a*np.cosh(s)
yi = 1/a*np.sinh(s)
xs.append(xi)
ys.append(yi)
dxs.append(dx)
dys.append(dy)
if s == 0:
ax.text(xi-0.75, yi+1.5, '$u$', transform=ax.transData)
ax.annotate('$a^{-1}$',
xy=(xi, yi), xycoords='data',
xytext=(25, -5), textcoords='offset points',
verticalalignment='top', horizontalalignment='left',
arrowprops=dict(arrowstyle='-', shrinkB=7))
ax.quiver(xs, ys, dxs, dys, scale=1.8, color='black', scale_units='xy', angles='xy',
width=0.01)
ax.plot(xs, ys, 'ko')
# http://stackoverflow.com/a/13430772/190597 (lucasg)
ax.set_xlim(-0.1, x.max())
left, right = ax.get_xlim()
low, high = ax.get_ylim()
ax.arrow(0, 0, right, 0, length_includes_head=True, head_width=0.15 )
ax.arrow(0, low, 0, high-low, length_includes_head=True, head_width=0.15 )
ax.text(0.03, 1, '$t$', transform=ax.transAxes)
ax.text(1, 0.47, '$x$', transform=ax.transAxes)
plt.axis('off')
ax.set_aspect('equal')
plt.show()
|
I want gird lines of x-axis and y-axis in highcharts but i don't want x-axis value and y-axis value
Date : March 29 2020, 07:55 AM
With these it helps May be this will help you.. use this logic in it.. fiddler$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
ignoreHiddenSeries : false
},
xAxis: {
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
data: [129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4]
}]
});
// the button action
var series = chart.series[0];
series.hide();
series = chart.series[1];
series.hide();
});
|
add axis lines to matplotlib plot
Date : March 29 2020, 07:55 AM
I wish this helpful for you The easiest way to accomplish this (without the fancy arrowheads, unfortunately) would be to use axvline and axhline to draw lines at x=0 and y=0, respectively: t = arange(-2, 2, 0.1)
y2 = exp(-t)
axhline(0,color='red') # x = 0
axvline(0,color='red') # y = 0
grid()
plot(t, y2, '-')
show()
|
matplotlib scatter plot with xyz axis lines through origin (0,0,0) and axis project lines to each point
Date : March 29 2020, 07:55 AM
Hope that helps Ok, so maybe there is a direct way of achieving this. If not, this code will solve the greatest part of your problem. I created a function which generates the dashed lines as needed. Use ax.quiver() to generate the coordinate system. EDIT: You can use commands like ax.set_axis_off()to generate the image you posted. from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
def make_dashedLines(x,y,z,ax):
for i in range(0, len(x)):
x_val, y_val, z_val = x[i],y[i],z[i]
ax.plot([0,x_val],[y_val,y_val],zs=[0,0], linestyle="dashed",color="black")
ax.plot([x_val,x_val],[0,y_val],zs=[0,0], linestyle="dashed",color="black")
ax.plot([x_val,x_val],[y_val,y_val],zs=[0,z_val], linestyle="dashed",color="black")
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = [1,1,-1]
y = [1,-1,1]
z = [1,1,-1]
ax.scatter( x,y,z, c='r', marker='o')
make_dashedLines(x,y,z,ax)
# Make a 3D quiver plot
x, y, z = np.array([[-2,0,0],[0,-2,0],[0,0,-2]])
u, v, w = np.array([[4,0,0],[0,4,0],[0,0,4]])
ax.quiver(x,y,z,u,v,w,arrow_length_ratio=0.1, color="black")
ax.grid(False)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_xlim(-2,2)
ax.set_ylim(-2,2)
ax.set_zlim(-2,2)
plt.show()
|
avoid sorting in X axis in matplotlib and plot common X axis with multiple y axis
Date : March 29 2020, 07:55 AM
will be helpful for those in need I wish to clarify two queries in this post. , Try to draw the series/dataframe against the index: col_to_draw = [col for col in df.columns if col!='col0']
# if your data frame is indexed as 0,1,2,... ignore this step
tmp_df = df.reset_index()
ax = tmp_df[col_to_draw].plot(figsize=(10,6))
xtick_vals = ax.get_xticks()
ax.set_xticklabels(tmp_df.col0[xtick_vals].tolist())
|