plotting – How to DensityPlot3D it?

I solve a Dirichlet problem on a parallelepiped in 3D

p = Parallelepiped({0, 0, 0}, {{1, 0, 0}, {1, 1, 0}, {0, 1, 1}});
sol = NDSolve({Laplacian(u(x, y, z), {x, y, z}) == 0, 
DirichletCondition(u(x, y, z) == x^4 + y^2 + z, True)}, u(x, y, z), {x, y, z} (Element) p)

{{u(x,y,z)->InterpolatingFunction(Domain: {{0.,2.},{0.,2.},{0.,1.}} Output: scalar)(x,y,z)}}

I’d like to vizualize that solution. Following the documentation,
I try

DensityPlot3D( u(x, y, z) /. sol, {x, 0, 2}, {y, 0, 2}, {z, 0, 1})

The above command works, but produces an empty plot without any error messages.
My next attempt is

Clear(x,y,z,u);DensityPlot3D(Evaluate(u(x, y, z) /. sol), {x, 0, 2}, {y, 0, 2}, {z, 0, 1})

enter image description here

with an unsatisfactory result as well as

Clear(x,y,z,u);DensityPlot3D(Evaluate(u(x, y, z) /. sol), {x, 0, 2}, {y, 0, 2}, {z, 0, 1}, 
 PlotPoints -> 20, WorkingPrecision -> 12)

enter image description here

The slices of sol are plotted well, for example,

Plot3D((u(x, y, z) /. sol) /. z -> 0.2, {x, 0, 2}, {y, 0, 2})

enter image description here

plotting – Frame ticks of array plot given by a list

SeedRandom[1]
M = RandomReal[1, {5, 10}];
x = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20};
y = {10, 11, 12, 13, 14};

{xticks, yticks} = MapIndexed[{#2[[1]], #} &, #] & /@ {x, y};

ArrayPlot[M, FrameTicks -> {{yticks, yticks}, {xticks, xticks}}]

enter image description here

You can also use

{yticks2, xticks2} = Thread /@ Thread[{Range[Dimensions[M]], {y, x}}];

{yticks2, xticks2} == {yticks, xticks}
 True

Alternative approach is to use the options DataRange and DataReversed and let ArrayPlot compute the frame ticks:

ArrayPlot[M, 
 DataReversed -> {True, False}, 
 DataRange -> MinMax /@ {x, y}, 
 FrameTicks -> All, 
 AspectRatio -> 1/2]

enter image description here

plotting – How to change the size of the y axis

I got this code but the solution is very tight in the Y axis, I wanna know how can I change the scale or the size of the Y axis and how can I obtain its solution cause it’s not as simple as sol/.t->n. Thanks a lot, any help would be appreciated.

sol = NDSolve({Ca'(t) == 
25 - 0.005 Ca(t) - 8 10^12 E^(-22500/(1.987 T(t) )) Ca(t), T'(t) == 
0.005 (300 - T(t)) + 
 0.01 (8 10^12 E^(-22500/(1.987 T(t) ))) Ca(t) - 
 0.001 (T(t) - 330), Ca(0) == 5000, T(0) == 330}, {Ca, T}, {t, 800})
ParametricPlot(Evaluate({Ca(t), T(t)} /. sol), {t, 0, 800})

enter image description here

plotting an inequality

Can anyone help in plot an inequallity

Abs[[x/[1 + x]] – [y/[1 + y]]] <= Abs[x – y]/[1 + 0.01 Abs[x – y]] where 0 < x< 1 and 0 < y< 1

When I tried with Plot command as well as Plot3D command, it is not displaying the output.

plotting – Limit Y-axis Evaluation but NOT the Plot Range

I have seen some answers to similar questions, but usually they are satisfied with just limiting the plot using PlotRange.
I want to keep the plot range as I have it, and just limit the range that is evaluated.
I don’t want to show that horizontal line at 90 (which is part of the output) so I want to limit the output to just above 90 (like 90.1) so that I can instead show the horizontal dashed line as the output approaches it asymptotically.
I think it does not tell the story as clearly if I just limit the range to 90 since it would be approaching the x-axis so I want to keep the displayed range down to 80.

ClearAll("Global`*")
eq1 = NSolve(0.5==(-(Pi)/3)r^3(1/Cos((Theta)*Degree)^3)(2+Sin((Theta)*Degree))(1-Sin((Theta)*Degree))^2, (Theta));
Labeled(Plot((Theta)/.eq1, {r,0.6203, 6} ,ImageSize->700,ImageMargins->0,ImagePadding->{{22, 10}, {15, 5}}, PlotRange-> {{0,6},{90,180}}, GridLines ->{{{0.62,Dashed}}, {{90, Dashed}}}, Ticks ->{{0,0.62,1,2,3,4,5,6},{10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180}}),{"Contact Angle ((Degree))","Tube Radius",  "Maximum Contact Angle for Plug of Volume 1 at Critical Bond Number" }, {Left, Bottom, Top}, RotateLabel -> True, Spacings ->{0,1,0})

plotting – How to make FindRoot work with PolyLog functions

I have the following code:

q = 1.6*10^-19;
hbar := 6.63/(2*(Pi))*10^-34;
m0 = 9.1*10^-31;
kb = 1.38*10^-23;
Cap := 4.5*10^-3;
W := 50*10^-6;
mu := 4.3*10^-4;
n := 20;
vth = ((3*kb*300)/m0)^0.5;
vt := -3.5;
Rex := 15 ;
vg = 0;
Plot(id /. 
  FindRoot((id - (Cap*W*mu*(n*vth)^2)/(
      7*10^-6)*(PolyLog(2, -Exp((vd - id - vg + vt)/(n*vth))) - 
        PolyLog(2, Exp((id - vg + vt)/(n*vth))))), {id, 
    10^-6}), {vd, -1, .872}, ImageSize -> Large, 
 AxesLabel -> {vd, id}, LabelStyle -> {15, Bold, Black})

It shows this error:

enter image description here

How can I specify the correct AccuracyGoal and PrecisionGoal for my problem. Also I want to plot the $id$ as a function of $vd$ for different $vg$, is there a way to automate it?

plotting – What regular cartesian expression $y=f(x)$ has a graph of the “number 7-like” shape?

7-shaped graph

It seems to be a simple question but I’m stuck. I was trying to transform many fuctions that are partly resembling 7 like $ax^3+bx^2+cx+d$, sawtooth wave, Heavyside step, $|x|$, a lot of trigonometry function family expressions, elliptic curve but failed to do what I need exactly. Finally I have to get an upside-down trapezoid-like graph like such:
upside-down trapezoid
with a single regular cartesian expression $y=f(x)$. All I’ve come up with is an upside-down triange with poorly drown discontinuities.
crazy triangle
However it was made with an implicit formula 0 == ((UnitStep(-y)*(2 + y*(2/3)))/Abs(x)) - 1 and ContourPlot after all which’s not acceptable.

ContourPlot({0 == ((UnitStep(-y)*(2 + y*(2/3)))/Abs(x)) - 1}, {x, -5, 
  5}, {y, -5, 5}, Exclusions -> None, WorkingPrecision -> 16)

I know there is a way to do something similar with transformation of a circle on the complex plane but it’s too difficult for me and I expect to produce the plot with reals.

plotting – HatchFilling between two data sets in LogLog scale for Mathematica 11.1

ClearAll(addHatchFilling)
addHatchFilling(mf_: Automatic, color_: Automatic, m_: Automatic) :=
   ReplaceAll(p_Polygon :> {p, 
     First(RegionPlot(DiscretizeRegion(p), 
       MeshFunctions -> (mf /. Automatic -> {# + #2 &}), 
       MeshStyle -> (style /. Automatic -> Directive(Thick, Opacity(1), White)), 
       Mesh -> (m /. Automatic -> 40), MeshShading -> None))}) @* Normal;

Examples:

{list1, list2} = {Transpose({Range @ 20, Range@20}), 
   Transpose({Range @ 20, Sqrt@Range@20})};

llp = ListLogLogPlot({list1, list2}, Joined -> True, 
  Filling -> {1 -> {2}}, ImageSize -> 400);

Row({llp, addHatchFilling()@llp}, Spacer(10))

enter image description here

Row({addHatchFilling({# &}, 
    Directive(Opacity(1), CapForm("Butt"), AbsoluteThickness(5), Orange), 30)@llp, 
  addHatchFilling({# &, #2 &}, Automatic, {20, 20}) @ llp}, Spacer(10))

enter image description here

Row({addHatchFilling({#2 &}, 
    Directive(Opacity(1), CapForm("Butt"), AbsoluteThickness(2), Red), 
     {Range(0, 20, .1)}) @ llp, 
  addHatchFilling({# + #2 &, #2 - # &}, Automatic, {20, 10})@llp}, 
 Spacer(10))

enter image description here

$Version
 "11.3.0 for Microsoft Windows (64-bit) (March 7, 2018)"

See also: Generating hatched filling using Region functionality

plotting – Problems With StreamPlot

I have the following vector functions:

$$E=leftlangle cosleft[frac{pi x}{5}right]sinleft[frac{pi y}{4}right], sinleft[frac{pi x}{5}right]cosleft[frac{pi y}{4}right], sinleft[frac{pi x}{5}right] sinleft[frac{pi y}{4}right] rightrangle$$

$$B=leftlangle -sinleft[frac{pi x}{5}right]cosleft[frac{pi y}{4}right], cosleft[frac{pi x}{5}right]sinleft[frac{pi y}{4}right],0 rightrangle$$

And I’d like to graph each of these in a different plane, so I want to know what they look like in the $xy$, $xz$, and $yz$ planes. Using stream plot I got a graph of the view in the $xy$ plane that I was happy with but with the other perspectives I’m finding them difficult to plot and I think it’s because I have to use $x$ and $y$ bounds for StreamPlot. So, I’m wondering if there is a way to graph these vector fields in the $xz$ and $yz$ plots so that I have functions that aren’t varying with respect to the $z$ axis? Because, for example, right now what I’m doing is just replacing the $x$ component with the $z$ component and graphing but since my $z$ component is in terms of $x$ it changes with the bounds which I don’t want it to do.

Manipulating lists based on conditionals and 3D plotting the smooth surface that bounds a list of points

First of all I want to create a list of evenly spaceed points in a cubic region in $mathbb{R}^3$. Then I want to keep the points in this list which satisfy a certain condition, i.e. a function that takes these points in $mathbb{R}^3$ and outputs true or false depending on the details of my problem. Then I need to plot these points using some sort of a interpolation function, which will be able to show the surface that bounds the volume that the points in my list are located in.

The selection criterion is the following:

There is a matrix $mathcal{M}=mathcal{M}(x,y,z)$ defined for every point in this list. Say for the point $P= (1,4,5)$, the matrix $mathcal
{M}(1,4,5)$
is Positive Semi-Definite, then I want to KEEP the point $(1,4,5)$. If at that point the matrix is nott Positive Semi-Definite, then I want to DISCARD that point.

My problem is

  1. I could not create a list comprised of evenly spaced points in $mathbb{R}^3$.
  2. I could not discard or keep the elements of a given set based on the output that an element of the list gives when inputed into a function.
  3. I could not create a smooth surface which bounds a list of points in $mathbb{R}^3$.

Basically If at a point the matrix is positive semi-definite, then I want to keep that point. If at a point the matrix is not positive semi-definite, then I want to discard that point.

If needed I can also provide my function, which is the criteria for keeping or discarding certain points, but I am afraid it will only serve to clutter the discussion.