## plotting – ScalingFunctions and DataRange in ListDensityPlot[]

I wanted to plot 100×100 two-dimensional array with certain units for x-y axis. In addition, I want to invert y-axis. I can do each of them separately. For example,

``````l = Table(x - y, {x, 1, 100}, {y, 1, 100});
ListDensityPlot(l, DataRange -> {{0, 1}, {0, 5}})
``````

shows the plot with different x-y scale.

and I can get plot with inverted y-axis by

``````ListDensityPlot(l, ScalingFunctions -> {Identity, "Reverse"})
``````

.

However, if I tried to do both,

``````ListDensityPlot(l, ScalingFunctions -> {Identity, "Reverse"},
DataRange -> {{0, 1}, {0, 5}})
``````

the resulting plot is almost blank (I saw a small region of plot at the top).

Is there any way to circumvent this problem?

Thank you very much in advance.

Takashi.

## Flatten for ListDensityPlot

How do I flatten a list of the form

``````{{{1, 2}, 3}, {{4, 5}, 6}, {{7, 8}, 9},...}
``````

to put it in the form

``````{{1, 2, 3}, {4, 5, 6}, {7, 8, 9},...}
``````

required to use ListDensityPlot? Thanks in advance for any help.

## graphics – Bug with plotting the Heatmap (ListDensityPlot) of a difference-equation

I am using
Mathematica Version Number 12.0.0.0
Platform: Microsoft Windows (64-bit)

The issue:
The Heatmap is not plotting properly for some specific initial condition (x(0)), the number of interactions (Tfinal), the constant value b, and parameter values (e, a, cs, ce, L). I illustrate this issue for the case in which x(0)=0.1, Tfinal=1500, b=1, e=8/10, a=36/203, cs=1/10, ce=17/3114, L=79/102.

``````(*Defining the initial condition, parameter values, and difference equation *)

Tfinal=1500; (*Number of interactions*)
step=0.01;

x0=0.1;     (*Initial condition*)

(*Parameters*)
b=1;        (*constant*)
e=8/10;     (*0 <= e <= 1*)
a=36/203;   (*0 <= a <= 1/2*)
cs=1/10;    (*0 <= cs <= 1/2*)
ce=17/3114; (*0 <= ce <= 1/4*)
L=79/102;   (*0 <= L <= 1*)

f(L_,e_,a0_,a_,cs_,cE_,ce_,x_(t)):= (x(t)*(1 - (ce + cE + cs)*(a0 + a*(L + x(t) - L*x(t))) + (e + x(t) - e*x(t))^b*(a0 + a*(L + x(t) - L*x(t)))))/
((1 - x(t))*(1 - a0*(ce + cs) + a0*e^b + (-((-1 + e)*x(t)))^b*(a0 + a*(L + x(t) - L*x(t)))) +
x(t)*(1 - (ce + cE + cs)*(a0 + a*(L + x(t) - L*x(t))) + (e + x(t) - e*x(t))^b*(a0 + a*(L + x(t) - L*x(t)))));
``````
``````(* Organizing the data so I can use ListDensityPlot *)

dat=Table({a0,cE,RecurrenceTable({x(t+1)==f(L,e,a0,a,cs,cE,ce,x(t)),x(0)==x0},x,{t,0,Tfinal})},{a0,0,1/2,step},{cE,0,1/4,step});

dat // MatrixForm; (*the way that the data come out from Table({a0,cE,RecurrenceTable({x(t+1)(Equal)f(L,e,a0,a,cs,cE,ce,x(t)),x(0)(Equal)x0},x,{t,0,Tfinal})},{a0,0,1/2,step},{cE,0,1/4,step})*)

parameters = Take(dat, All, All, 2); (*only getting parameter values used to run the model:=getting all rows and collumns of 2 first values*)
parameters// MatrixForm;

d=Dimensions(parameters);
d((2)) ;(*colecting the number of columns*)

dat((;; , ;; , 3, -1)) // MatrixForm; (*only getting values of x(Tfinal)*)
xFinal=Flatten(dat((;; , ;; , 3, -1))); (*putting x(Tfinal) into a single list*)
xFinal2=Partition(xFinal,1);(*first step in x(Tfinal) partitioning*)
xFinal3=Partition(xFinal2,d((2))); (*last step in x(Tfinal) partitioning*)

dataOrg=Join(parameters,xFinal3,3);(*combining the parameters and x(Tfinal) lists by at each 3 location of "parameters" list inputinng "xFinal3"*)
dataOrg//MatrixForm;

dataOrg2=Flatten(dataOrg,1); (*colapting the data in one list*)
dataOrg2//MatrixForm;
``````
``````ListDensityPlot(dataOrg2
,FrameLabel->{Style("!(*SubscriptBox((a), (0)))",15,"DisplayFormula"),Style("!(*SubscriptBox((c), (E)))",15,"DisplayFormula")}
,ColorFunction->"BrownCyanTones"
,PlotLegends->Placed(BarLegend(Automatic,LegendLabel->"x(t)"),After))
``````

Notice that the heatmap is correctly plotting when x(t)==1 (in blue), but not when x(t) is near zero (which should be brown instead of white).
The time series gives an example that the blue area is correct but that the white area should be brown:
At a0=0.4 and cE=0.2, x(Tfinal) = 6.74504*10^-12, which should be brown in the heatmap, instead of white.

``````(*Now calculating a time series *)
Tfinal=1500;

a0=0.4;  cE=0.20;

timeSeries=RecurrenceTable({x(t+1)==f(L,e,a0,a,cs,cE,ce,x(t)),x(0)==x0},x,{t,0,Tfinal});

ListPlot(timeSeries, PlotRange->{{0.0,1.05}})

timeSeries((1))(*value of x(0)*)
timeSeries((Tfinal)) (*value of x(Tfinal)*)
``````

At a0=0.4 and cE=0.1, x(Tfinal) = 1, which is show correctly in the heatmap as blue.

``````Tfinal=1500;
a0=0.4;  cE=0.1;

timeSeries=RecurrenceTable({x(t+1)==f(L,e,a0,a,cs,cE,ce,x(t)),x(0)==x0},x,{t,0,Tfinal});

ListPlot(timeSeries, PlotRange->{{0.0,1.05}})

timeSeries((1))(*value of x(0)*)
timeSeries((Tfinal)) (*value of x(Tfinal)*)
``````

The issue disappears by doing any of the following:

1. By changing the initial condition of the variable, e.g., x(0)=x0=0.2;
2. By using other parameter values. However, for certain parameter values, e.g., ce={17/3114, 18/3114}, the problem is maintained.
3. To change the number of interactions. Bug in the heatmap when assuming Tfinal = {300, 400,500,600,700,800,900,1000,1100,1200,1300, 1400,1500}, in which among those two types of bug in the bar legend occur. One bug is having several denominator happens when Tfinal ={700,800,900,1000,1100,1200,1300}. The other bug is having all value of the legend being “1”, this issue occurs when TFinal ={1400,1500}. Examples of Tfinal values in which is no bug in the graph Tfinal= {100,200, 1600,1700,1800, 1900}.
Detail, when I run the same code in Mathematica Version 12.1.1.0, Platform: Linux x86 (64-bit)
the following Tfinal ={900, 1000,1500} that in the Version 12.0.0.0 were a issue, is not an issue anymore. Examples of the same issue in Mathematica Version 12.1.1.0 are found when Tfinal = {800, 700, 600, 500, 400, 300}.

PS.:The issue does not seem to be related to the choice of ColorFunctions, because I tried other ColorFunctions, and the problem didn’t change.

## plotting – Custom Scaling Function for ListDensityPlot not working

I’m attempting to plot a data set with values that span multiple orders of magnitude, both positive and negative. I would like to use a Logorithmic scaling to accurately capture this order of magnitude change, but needed to define a custom function to deal with the negative values. I’ve included the scaling function I use (aL) and its inverse (aE) as well as equivalent code

`xR=Table((Exp(0.06225 i)-1),{i,1,150});`

`xt= Table(0.5 i,{i,1,500});`

`Lt=Length(xt);LR=Length(xR);`

`Do(tdata(j) = Sort(Table(RandomReal({-5, 5})*10^RandomInteger({5, 50}), {i, 1, LR})), {j, 1, Lt});`

`Pdat = Flatten(Table({xt((j)), xR((z)), tdata(j)((z))}, {j, 1, Lt}, {z, 1, LR}), 1);`

`aL = Sign(#) Log(1 + Abs(#)) &;`

`aE = Sign(#) (Exp(Abs(#)) - 1) &;`

`ListDensityPlot(Pdat, ColorFunction -> "BlueGreenYellow", PlotLegends -> True, ScalingFunctions -> {None, "Log", {aL, aE}})`

The plot this creates doesn’t look quite right, and the plot legend is a blank bar. I get the following error message:

Coordinate {Indeterminate, Indeterminate} should be a pair of numbers, or a Scaled or Offset form.

## Artifacts / snippets when plotting more than a few hundred samples with ListDensityPlot

I have artifacts / clippings when plotting more than a few hundred samples `ListDensityPlot`:

``````Row[
ListDensityPlot[Take[ping,{1,4},{1, 50}] , DataRange->All,ImageSize->300],
ListDensityPlot[Take[ping,{2,4},{1, 50}] , DataRange->All,ImageSize->300]
]
``````

In the upper left area of ​​the first image you will see a white area, just like with missing data. However, if you reduce the number of samples, the problem will go away.

Here is the subset of the data shown in this example encoded as CSV:

``````0.09435165673494339,0.026477808132767677,0.19732601940631866,0.26556509733200073,0.07613298296928406,0.19793230295181274,0.4582083523273468,0.41589951515197754,0.08203661441802979,0.19487760961055756,0.605080783367157,0.47728514671325684,0.07539505511522293,0.36840906739234924,0.4184708595275879,0.10306259244680405,0.11297939717769623,0.24305465817451477,0.12937937676906586,0.0150202177464962,0.08175915479660034,0.18627282977104187,0.12698423862457275,0.01031533908098936,0.03846200183033943,0.049766283482313156,0.026876576244831085,0.01110867690294981,0.0016435502329841256,0.00029462549719028175,0.00018642170471139252,0.0061373901553452015,0.02980426698923111,0.030406605452299118,0.010827901773154736,0.007469639647752047,0.029858319088816643,0.06169850751757622,0.06414280831813812,0.009315243922173977,0.062189847230911255,0.07532260566949844,0.01263517513871193,0.0018671300495043397,0.0015888283960521221,0.004361136816442013,0.01960695907473564,0.012605090625584126,0.004123216960579157,0.0118645578622818
0.09634332358837128,0.02686469629406929,0.20518483221530914,0.28278276324272156,0.08598637580871582,0.19014398753643036,0.45788848400115967,0.42082783579826355,0.08614698797464371,0.19386743009090424,0.6057818531990051,0.4786321818828583,0.08032963424921036,0.3828735947608948,0.4295917749404907,0.10898793488740921,0.11061027646064758,0.24385854601860046,0.1299978792667389,0.015442855656147003,0.08075147867202759,0.18609391152858734,0.12211965024471283,0.008748708292841911,0.04163325950503349,0.053123876452445984,0.026498621329665184,0.009793965145945549,0.0013109392020851374,0.0003139302134513855,0.00037488079397007823,0.007548886351287365,0.0378672331571579,0.0421636737883091,0.0170101597905159,0.0040002199821174145,0.026331359520554543,0.06250255554914474,0.06812327355146408,0.00996074266731739,0.05982403829693794,0.07401321828365326,0.011222387664020061,0.0008733587455935776,0.003431713907048106,0.00648933369666338,0.020725682377815247,0.013090439140796661,0.003957836423069239,0.011257689446210861
0.09525042027235031,0.026391958817839622,0.19234007596969604,0.2669665515422821,0.07677695900201797,0.1963191032409668,0.4594137668609619,0.41874298453330994,0.08443199843168259,0.19637806713581085,0.6077036261558533,0.47999468445777893,0.07647191733121872,0.3717271089553833,0.41909706592559814,0.1035907119512558,0.11028275638818741,0.2415691763162613,0.12895730137825012,0.014560800045728683,0.08477040380239487,0.18928371369838715,0.133210226893425,0.010850082151591778,0.035475682467222214,0.04946177452802658,0.027140531688928604,0.011302179656922817,0.0018958889413625002,0.0003548233362380415,0.00019814963161479682,0.006933570373803377,0.030390189960598946,0.03341860696673393,0.01208744291216135,0.005270918365567923,0.026850134134292603,0.06073543056845665,0.06502803415060043,0.009488476440310478,0.06173449382185936,0.07461918145418167,0.015114754438400269,0.0020436851773411036,0.0015562578337267041,0.004906554240733385,0.020263561978936195,0.01256541721522808,0.004010625649243593,0.012095853686332703
0.23765338957309723,0.2846621870994568,0.6251108050346375,0.265604704618454,0.7681690454483032,0.7086784839630127,0.5982181429862976,0.8564531207084656,0.624255359172821,0.8060227632522583,0.7584503293037415,0.15571729838848114,0.48091408610343933,0.49679580330848694,0.12461533397436142,0.03487076610326767,0.1937306970357895,0.28145962953567505,0.13398262858390808,0.2376774251461029,0.2978552281856537,0.046651870012283325,0.15761131048202515,0.027403783053159714,0.05551522225141525,0.015894366428256035,0.0716162770986557,0.01613367721438408,0.12092642486095428,0.09966622292995453,0.051298078149557114,0.18218792974948883,0.06692558526992798,0.11383642256259918,0.17555710673332214,0.03568575158715248,0.19956129789352417,0.09862546622753143,0.13952267169952393,0.10615747421979904,0.11866769194602966,0.07875005155801773,0.1662282794713974,0.08570600301027298,0.10994847118854523,0.18946002423763275,0.07776174694299698,0.21340516209602356,0.048199038952589035,0.15901124477386475
``````

My actual data consists of $$60 times 250$$ Patterns and entire areas of the property are missing. How can i do `ListDensityPlot` display all Data?

FWIW, I'm working on the Wolfram Cloud.

## Plotting – ListDensityPlot and DensityPlot do not deliver the same results?

I'm drawing the same function `ListDensityPlot` and `DensityPlot` but the output is different!
There are some points where the function is complex or purely imaginary `DensityPlot`Show this region as white. However, `ListDensityPlot` show staining in the same region.

``````mod = ParallelTable[
With[{[Kappa] = 0.23}, {ky, [Epsilon],
Sqrt[-ky^2 + [Epsilon]^2 + [Kappa]^2 -
Sqrt[[Epsilon]^2 - 4 ky^2 [Kappa]^2 +
4 [Epsilon]^2 [Kappa]^2]]}], {ky, -0.35, 0.35,
0.001}, {[Epsilon], 0, 0.2, 0.001}];
ListDensityPlot[Flatten[mod, 1]]
``````

``````With[{[Kappa] = 0.23},
DensityPlot[
Sqrt[-ky^2 + [Epsilon]^2 + [Kappa]^2 -
Sqrt[[Epsilon]^2 - 4 ky^2 [Kappa]^2 +
4 [Epsilon]^2 [Kappa]^2]], {ky, -0.35, 0.35}, {[Epsilon],
0, .2}, PlotRange -> Full, Exclusions -> None, PlotPoints -> 50]]
``````

## Plotting – How do I get the values ​​of a ListDensityPlot?[]

A simulation output indicates X Y Z positions and whether there is an error (1) or a success (0). My data is in (file.dat). I tested

``````daall = Import["data_all.dat"]
ListDensityPlot3D[daall, PlotLegends -> Automatic,
ColorFunction -> "TemperatureMap"]
``````

and the 2D projection in the XY plane

``````ListDensityPlot[Map[({#[[1]], #[[2]], #[[4]]}) &, daall],
PlotLegends -> Automatic, ColorFunction -> "TemperatureMap"]
``````

and the presentation of the two looks different. In the 3D image, some zones have values ​​between 0 and 1. In the 2D image, however, there are no intermediate values ​​(0.4, 0.6, …).

I would like to ask why they are different, how I could get these intermediate values ​​in the image, and how I could get all the points used in both plots. For example, I would like to extract the data values ​​of the 2D Diagram (LisDensityPlot), save those data points in a file, and try to represent them `ArrayPlot[]`,

## Plotting – Why does ListDensityPlot not work?

I can not figure out how this ListDensityPlot function works.

From the website:

``````                    ListDensityPlot[{{x1,y1,f1},{x2,y2,f2},…}]
``````

I write

``````                ListDensityPlot[{{24.5, 20.5, 0.109}, {25.5, 20.5, 0.198}, {26.5,
20.5, 0.338}, {27.5, 20.5, 0.53}, {28.5, 20.5, 0.82}, {29.5, 20.5,
1.2}}]
``````

and there is only a completely white plot.