I am trying to make the following plot:
Pars = {ep -> 0.5, f1p -> 0.3, f2p -> 0.1, dp -> 0.05, q -> 0.1,
en -> 0.4, d -> 0.1, Q -> 0.1, f2n -> 0.3, f1n -> 0.4, a -> 0.05,
N1 -> 0.5, N2 -> 0.5}; #Parameters
PlotREq1 =
Plot[R = S /. Pars, {S, 0, 0.9375},
PlotRange -> {{0, 3.5}, {0, 2}}, PlotStyle -> {Red, Thick, Dashed},
GridLines -> {{0.9375}, {}}];
PlotREq2 =
Plot[R = (a + d)/(en f1n) /. Pars, {S, 0.9375, 1.4375},
PlotRange -> {{0, 3.5}, {0, 2}}, PlotStyle -> {Red, Thick, Dashed},
GridLines -> {{1.4375}, {}}];
PlotREq3 =
Plot[R = ((a + d) (f1p - f2p))/(en (f1p f2n - f1n f2p)) /. Pars, {S,
1.4375, 2.3}, PlotRange -> {{0, 3.5}, {0, 2}},
PlotStyle -> {Red, Thick, Dashed}, GridLines -> {{2.3}, {}}];
Show[PlotREq1, PlotREq2, PlotREq3]
However, only the first gridline shows up and the other two vertical lines at 1.4375 and 2.3 do not appear. Also, can anyone suggest a way to label the gridlines? I tried to insert a axeslabel within the Gridline function as: Gridlines -> {{{0.9375},{}}, AxesLabel -> {"R",""}} but it does not seem to work.
Using Show, only the first version of an option is followed. Place all the gridlines in the first plot, or add them as options to Show, which will override any others.
Show[PlotREq1, PlotREq2, PlotREq3, GridLines -> {{0.9375, 1.4375, 2.3}, {}}]
Related
I would like to plot two functions in one plot with one x-axis and two different y-axis. I tried to used the overlay function but the result cannot be satisfied.
ZS1 = {{820, 30}, {860, 40}, {880, 50}, {900, 60}, {920, 70}, {930,
80}, {940, 90}};
plot1 = ListLinePlot[ZS1, PlotStyle -> Blue,
Frame -> {True, True, True, False},
ImagePadding -> 25,
FrameStyle -> {Automatic, Blue, Automatic, Automatic}]
theta1 = {{980, 0.3}, {960, 0.4}, {920, 0.5}, {880, 0.8}, {800,
1.1}};
plot2 = ListLinePlot[theta1, PlotStyle -> Red,
ImagePadding -> 25, Axes -> False,
Frame -> {True, False, False, True},
FrameTicks -> {{None, All}, {All, None}},
FrameStyle -> {Automatic, Automatic, Automatic, Red}]
Overlay[{plot1, plot2}]
I accomplished by using the "CombinePlots" function.
ResourceFunction["CombinePlots"][ListLinePlot[ZS1, PlotStyle -> Blue, Frame -> True, FrameStyle -> Blue], ListLinePlot[theta1, PlotStyle -> Red, Frame -> True, FrameStyle -> Red], "AxesSides" -> "TwoY", FrameLabel -> {Style["Frequency (MHz)", 14], Style["ZS1", 14], None, Style["\[Theta]1", 14]}, GridLines -> Automatic]
My Script ceases to work for my easy conduction problem. Could somebody explain to me why the following line of code T.faceValue.constrain(alp/lam*(Tu-T.faceValue),where=mesh.exteriorFaces) # Boundary Condition for Solver results in fipy giving up on me?
Full Code:
cv=900.
lam=5.
alp=300.
T0 = 25.
Tu = 400.
cellSize = 0.05
radius = 1.
mesh = Gmsh2D('''
cellSize = %(cellSize)g;
radius = %(radius)g;
Point(1) = {0, 0, 0, cellSize};
Point(2) = {-radius, 0, 0, cellSize};
Point(3) = {0, radius, 0, cellSize};
Point(4) = {radius, 0, 0, cellSize};
Point(5) = {0, -radius, 0, cellSize};
Circle(6) = {2, 1, 3};
Circle(7) = {3, 1, 4};
Circle(8) = {4, 1, 5};
Circle(9) = {5, 1, 2};
Line Loop(10) = {6, 7, 8, 9};
Plane Surface(11) = {10};
''' % locals()) # doctest: +GMSH
T = CellVariable(name = "HeatingUp",mesh = mesh,value = T0)
viewer = None
if __name__ == '__main__':
try:
viewer = Viewer(vars=T, datamin=T0, datamax=Tu)
viewer.plotMesh()
input("Irregular circular mesh. Press <return> to proceed") # doctest: +GMSH
except:
print("Unable to create a viewer for an irregular mesh (try Matplotlib2DViewer or MayaviViewer)")
# =============================================================================
eq = TransientTerm(coeff=rho*cv)==DiffusionTerm(coeff=lam)
T.faceValue.constrain(alp/lam*(Tu-T.faceValue),where=mesh.exteriorFaces) # Boundary Condition for Solver
timeStepDuration = 0.1
steps = 10
for step in range(steps):
eq.solve(var=T, dt=timeStepDuration) # doctest: +GMSH
if viewer is not None:
viewer.plot() # doctest: +GMSH
``
You've written that T.faceValue depends on T.faceValue, which depends on T.faceValue, which depends on T.faceValue, ... FiPy has dutifully provided you with the infinite loop that you requested.
Just write T.faceValue.constrain(Tu * (alp/lam) / (1 + alp/lam), where=mesh.exteriorFaces).
In the more likely event that you wanted to relate the gradient to the value at the boundary, please see the discussion on Robin conditions.
I have a plot where I plot different equations in each chunk of the graph. Using text, I want to write a small notation for each piece of the equation. The Text function does not yield the result. Also is there a way to specify the coordinates of the text? For example, I want the text reading Eqn 1 (see below) to be placed at (0, 0.5)
Here is my code:
Pars = {ep -> 0.5, f1p -> 0.3, f2p -> 0.1, dp -> 0.05, q -> 0.1,
en -> 0.4, d -> 0.1, Q -> 0.1, f2n -> 0.3, f1n -> 0.4, a -> 0.05,
N1 -> 0.5, N2 -> 0.5}; #Parameters
PlotREq1 =
Plot[R = S /. Pars, {S, 0, 0.9375},
PlotRange -> {{0, 3.5}, {0, 2}}, PlotStyle -> {Red, Thick, Dashed},Text[Eqn1]];
PlotREq2 =
Plot[R = (a + d)/(en f1n) /. Pars, {S, 0.9375, 1.4375},
PlotRange -> {{0, 3.5}, {0, 2}}, PlotStyle -> {Green, Thick, Dashed}, Text[Eqn2]];
PlotREq3 =
Plot[R = ((a + d) (f1p - f2p))/(en (f1p f2n - f1n f2p)) /. Pars, {S,
1.4375, 2.3}, PlotRange -> {{0, 3.5}, {0, 2}},
PlotStyle -> {Blue, Thick, Dashed}, Text[Eqn3]];
Show[PlotREq1, PlotREq2, PlotREq3]
Show[PlotREq1, PlotREq2, PlotREq3,
Epilog -> {
Inset[Framed[Style["Eqn 1", 14], Background -> White, FrameStyle -> None], {0.5, 0.5}],
Inset[Style["Eqn 2", 14], {1.18, 1.05}],
Inset[Style["Eqn 3", 14], {1.9, 1.6}]}]
I have this python code:
import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as axes3d
from matplotlib import cm
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Plot solid of revolution along x-axis
def sor_x(ll, ul):
u = np.linspace(ll, ul, 60)
v = np.linspace(0, 2 * np.pi, 60)
U, V = np.meshgrid(u, v)
X = U
Y = (U**2)*np.cos(V)
Z = (U**2)*np.sin(V)
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
ax.plot_surface(X, Y, Z, cmap=plt.cm.YlGnBu_r)
if __name__ == '__main__':
ll, ul = 0, 1
sor_x(ll, ul)
plt.show()
This plots the solid of revolution of function y = x**2 along x-axis. Now I have to change this to a 3D animation like this:
The code for this animation in mathematica is:
f[r_, ϕ_, z_] := {(2 + Tan[z])Cos[ϕ], (2 + Cos[z]) Sin[ϕ], z}
vase[α_] :=
ParametricPlot3D[f[r, ϕ, z], {z, 0, 2 Pi}, {ϕ, 0, α},
AspectRatio -> Automatic, PlotRange -> {{-3, 3}, {-3, 3}, {0, 6}}];
animation = Table[
vase[ϕ],
{ϕ, 0.1, 2π, π/12}];
Export["rotationskoerper_animation.gif", animation,
ConversionOptions -> {"AnimationDisplayTime" -> 0.1, "Loop" -> True},
ImageSize -> {1000, 1000}]
When I create and plot this list:
var = 2;
okList = {{0.8, var, 0.8, 0.8}, {0, 0.3, 0.6, 0.9}, {0, 1, 2, 3}};
lp = ListDensityPlot[okList, ColorFunction -> "SandyTerrain"]
or, unscaled, like this:
lp = ListDensityPlot[okList, ColorFunction -> "SandyTerrain",
ColorFunctionScaling -> False]
I get a fully coloured square, as I'd expect.
But when I try this:
var = 0.8;
list = {{0.8, var, 0.8, 0.8}, {0, 0.3, 0.6, 0.9}, {0, 1, 2, 3}};
problem = ListDensityPlot[list, ColorFunction -> "SandyTerrain"]
I get a white patch in the corner.
which plotting with ColorFunctionScaling->False doesn't get rid of
The ColorFunction SandyTerrain doesn't have any white in it, so this must be ListDensityPlot not plotting anything in that area.
What could cause this to happen, and how do I stop it?
It's getting clipped by the automatic plot range calculation. Try with PlotRange -> All or ClippingStyle -> Automatic.