plotting – RegionPlot edges with different BoundaryStyles?

I executed this command:

RegionPlot[x > 2 && x < 3 && y > 2 && y < 3, {x, 0, 4}, {y, 0, 4}]

enter image description here

I would like the top and right sides of the square to be dashed lines and the bottom and left sides of the square to be thick, solid lines. How do I do this?

plotting – Solve for not y=0 but for y=n

Let’s see if I manage to explain this well enough. I need to find roots of an equation(let’s say a cubic) but not at the points where the slope crosses the x axis(y=0), like the Solve function does by default, I need roots of y=2 for example.

This should be so simple I think yet I’m not sure how to do that.

plotting – Superimposed (put curves on top of each other) in one region

How to give a different color?

The raw data is a list of 1400 coordinate points. The data can be reshaped as 5 individual lists of 280 coordinate pairs.

Clear[data]
Get["https://pastebin.com/raw/AVFwHkC8", "Data"];
newshape = ArrayReshape[data, {5, 280, 2}];

Now ListPlot[newshape] will give a different color to each curve.

How to superpose the curves without distortion?

An approximate way is to shift each curve up or down so its 50th data point, say, lies on the x-axis. Plots at different scales show the 5 shifted curves happen to cross one another at points near x=49.54.

shifted = # /. {x_, y_} :> {x, y - #[[50, 2]]} &  /@ newshape;
ListPlot[shifted, PlotRange -> All]
ListPlot[shifted, PlotRange -> {{20, 85}, {-1, 1}}]
ListLinePlot[shifted, PlotRange -> {{40, 65}, {-0.025, 0.025}}]

enter image description here

The last plot hints at the amount of distortion that would be required to really superimpose the curves throughout the region.

Sensitivity

As it turns out, choosing the 50th data point of each curve worked fairly well. But what if another index had been used? We can use Manipulate to test other values of the index like this:

Manipulate[
 shifted = # /. {x_, y_} :> {x, y - #[[ndx, 2]]} &  /@ newshape;
 GraphicsColumn[{
   ListPlot[shifted, PlotRange -> All, ImageSize -> Small],
   ListLinePlot[shifted,
    PlotRange -> {{40, 65}, {-0.025, 0.025}}, 
    ImageSize -> Small]
   }],
 {{ndx, Length[shifted[[1]]]/5, ndx}, 1, Length[shifted[[1]]], 1}]

enter image description here

We can change the value of the index to see how that affects the overlay of the curves.

Toward an automated method

It may be possible to use the manipulator on several different datasets to develop a method of choosing the index that determines the amount of the shift. For instance, it may be found that 20th data point is a good choice if the curves are to overlay between x=20 and x=40.

Another strategy may be to shift the curve so that some data point near the middle of the valley between the first two peaks lies on the x-axis.

Combine PeakDetect and Position commands to find the indices for the peaks and take it from there.

PlotLegends

The questions on this site contain many good examples of using PlotLegends. If you have a some specific case that is not working for you, please post the troublesome code in a new question.

plotting – How to plot the given trihexagonal network?

Following my previous question

How to plot the given graph (irregular tri-hexagonal) with Mathematica?

I need a 2D network of the Fig. $a$, something like Fig. $b$ with red points on all vertices. Since I have drawn Fig. $b$ manually, it is not precise and symmetric.
In this case, the blue and the violet edges have different lengths.

enter image description here

Problems in plotting a function of two variables

Clear("Global`*")

a = Re(Sqrt(x^2 - 2 x y + y^2 - 1^2));

You cannot take the derivative of a function which contains Re. Use ComplexExpand to avoid use of Re

mat = {{0, -a/Sqrt((x - y)^2 + Abs(a)^2)}, {(x - y)/
       Sqrt((x - y)^2 + Abs(a)^2), 0}} // 
    ComplexExpand(#, TargetFunctions -> {Re, Im}) & // Simplify;

d1 = D(mat, x);
d2 = Simplify(mat . d1, {x >= 0, y >= 0});
fun(x_, y_) = Simplify(
   Tr(d1 . d1) + (1/Det(mat)) Tr(d2 . d2),
   {x >= 0, y >= 0});

Plot3D(
  fun(x, y), {x, 0, 5}, {y, 0, 5},
  PlotPoints -> 75,
  MaxRecursion -> 5,
  ClippingStyle -> None) // Quiet

enter image description here

plotting – No plot generated for this function

The function fun(x,y) defined below is not plotted for some reason. Is there a way to fix it and generate a plot?

fun(x_, y_) = ((x - 
    y)^4 (Sqrt(-1 + x^2 - 2 x y + y^2)
      Re(Sqrt(-1 + x^2 - 2 x y + y^2)) - (x - y)^2 Derivative(1)(
      Re)(Sqrt(-1 + x^2 - 2 x y + y^2)) + 
    Re(Sqrt(-1 + x^2 - 2 x y + y^2))^2 (-1 + 
       Derivative(1)(Abs)(
        Re(Sqrt(-1 + x^2 - 2 x y + y^2)))) Derivative(1)(Re)(
      Sqrt(-1 + x^2 - 2 x y + y^2)))^2 + 
 Re(Sqrt(-1 + x^2 - 2 x y + 
    y^2))^4 (Sqrt(-1 + x^2 - 2 x y + y^2)
      Re(Sqrt(-1 + x^2 - 2 x y + y^2)) - (x - y)^2 Derivative(1)(
      Abs)(Re(Sqrt(-1 + x^2 - 2 x y + y^2))) Derivative(1)(Re)(
      Sqrt(-1 + x^2 - 2 x y + y^2)))^2 + 
 8 (x - y)^2 Re(
   Sqrt(-1 + x^2 - 2 x y + y^2))^2 ((x - y)^2 + 
    Re(Sqrt(-1 + x^2 - 2 x y + 
      y^2))^2) (-Sqrt(-1 + x^2 - 2 x y + y^2) Re(
      Sqrt(-1 + x^2 - 2 x y + y^2)) + (x - y)^2 Derivative(1)(Re)(
      Sqrt(-1 + x^2 - 2 x y + y^2)) - 
    Re(Sqrt(-1 + x^2 - 2 x y + y^2))^2 (-1 + 
       Derivative(1)(Abs)(
        Re(Sqrt(-1 + x^2 - 2 x y + y^2)))) Derivative(1)(Re)(
      Sqrt(-1 + x^2 - 2 x y + y^2))) (-Sqrt(-1 + x^2 - 2 x y + 
       y^2) Re(
      Sqrt(-1 + x^2 - 2 x y + y^2)) + (x - y)^2 Derivative(1)(
      Abs)(Re(Sqrt(-1 + x^2 - 2 x y + y^2))) Derivative(1)(Re)(
      Sqrt(-1 + x^2 - 2 x y + y^2))))/(4 (x - y) (-1 + x^2 - 
   2 x y + y^2) Re(
  Sqrt(-1 + x^2 - 2 x y + y^2)) ((x - y)^2 + 
   Re(Sqrt(-1 + x^2 - 2 x y + y^2))^2)^4);


Plot3D(fun(x, y), {x, 0, 5}, {y, 0, 5})

plotting – Put two symbols in a legend at the same time

If I have the following data:

lengthscale1SB = {{0, 3.8070469267093143`}, {0, 
    3.6334805550267246`}, {0, 3.5421004645025067`}, {0, 
    3.1777415559882036`}, {0, 3.5382988573632863`}, {0, 
    2.8210206229841543`}};

Which plotted like:

qDSClabel = {"1 K/min", "2 K/min", "5 K/min", "10 K/min", "20 K/min", 
   "30 K/min"};

ListPlot(List /@ lengthscale1SB, Frame -> True, FrameStyle -> 16, 
 Axes -> False, GridLines -> Automatic, 
 GridLinesStyle -> Lighter(Gray, .8), 
 FrameTicks -> {Automatic, Automatic}, 
 FrameLabel -> (Style(#, 20, Bold) & /@ {"y", 
     Row({"x", " (", " units)"})}), ImageSize -> Large, 
 LabelStyle -> {Black, Bold, 14}, 
 PlotStyle -> {Red, Blue, Darker(Green), Black, Cyan, Gray}, 
 PlotLegends -> Placed(Defer /@ qDSClabel, {0.1, 0.25}))

gives:

enter image description here

Questions

How can I put two symbols in the legend? For example, right now it is “circle” 1 K/min, “circle” 2 K/min and so on. So, specifically, how can I put something like “cirle” “triangle” 1 K/min and so on?. Can this be done easily modifying slightly: PlotLegends -> Placed(Defer /@ qDSClabel, {0.1, 0.25})?

plotting – Using ListPlot3D with custom colours

You can achieve this using the option ColorFunctionof ListPlot3D.

We first create test some data, then define the color function and finally make the plot:

dat = Flatten[
   Table[{x, y, Sin[x y], Sin[x ]^2 Sin[y ]^2}, {x, 0, Pi, Pi/20}, {y,
      0, Pi, Pi/20}], 1];

col = Interpolation[dat[[All, {1, 2, 4}]]];
colfunction := Function[{x, y, z}, RGBColor[col[x, y], 0, 1 - col[x, y]]];

ListPlot3D[dat[[All, 1 ;; 3]], ColorFunction -> colfunction, 
 ColorFunctionScaling -> False]

enter image description here

plotting – Mathematica Loop for a pattern

Thanks for contributing an answer to Mathematica Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

plotting – Can the gap in my Plot be reduced?

The following plot

With({staffcr = 0.45, othercr = 0.125, papp = 1.0 (2/12), pdata = 1.0 (23370/12)}, ContourPlot(-88120.` + 0.9500000000000001` ndata pdata - 0.9999999999999999` ndata othercr pdata -0.9999999999999999` ndata pdata staffcr - 11542.58115183246` napp papp (-0.9500000000000001` + othercr + staffcr) - 0.9999999999999999` Max(15000, 0.08833053395066709` (2204633 napp + 9550 ndata)^0.646`) == 0, {napp, 0, 400}, {ndata, 0, 400}))

produces a gap or discontinuous jump in my Plot. The reason seems to be the use of Max in the formula.

The question is, can the gap be made smaller using some setting about axis, perhaps, or is Mathematica revealing a precise jump?

enter image description here