Repository: yt-project/yt

Issue:
sliceplot data range ignored when log with negative data
<!--To help us understand and resolve your issue, please fill out the form to
the best of your ability.-->
<!--You can feel free to delete the sections that do not apply.-->

### Bug report

**Bug summary**

If I specify a range for my data using the slice plot method `.set_zlim()`, it is ignored with the warning:
```
yt : [WARNING  ] 2020-01-04 15:10:13,211 Switching to symlog colorbar scaling unless linear scaling is specified later
```
if there are negative values in the dataset even if I am only asking for positive values in the range.

**Code for reproduction**

<!--A minimum code snippet required to reproduce the bug, also minimizing the
number of dependencies required.-->

<!-- If you need to use a data file to trigger the issue you're having, consider
using one of the datasets from the yt data hub (http://yt-project.org/data). If
your issue cannot be triggered using a public dataset, you can use the yt
curldrop (https://docs.hub.yt/services.html#curldrop) to share data
files. Please include a link to the dataset in the issue if you use the
curldrop.-->

```python
import yt
import numpy as np

npts = 32
lexp = 14
hexp = 17

arr = (hexp - lexp) * np.random.random_sample((npts, npts, npts)) + lexp
arr = 10.0**arr

arr[0,:,:] *= -1.0

data = dict(density = (arr, "g/cm**3"))
bbox = np.array([[-1.5, 1.5], [-1.5, 1.5], [-1.5, 1.5]])
ds = yt.load_uniform_grid(data, arr.shape, length_unit="cm", bbox=bbox)

slc = yt.SlicePlot(ds, "z", ["density"])
slc.set_zlim("density", 1.e14, 3.e17)
slc.save()
```
This code reproduces the problem.  The range I asked for, 1.e14 to 1.e17 is ignored when there is negative data.  If you comment out the line that negatives a slice through `arr`, then things work as expected.

**Actual outcome**

<!--The output produced by the above code, which may be a screenshot, console
output, etc.-->

```
# If applicable, paste the console output here
#
#
```

**Expected outcome**

<!--A description of the expected outcome from the code snippet-->
<!--If this used to work in an earlier version of yt, please note the
version it used to work on-->

The specified limits from `set_zlim()` should be respected.

**Version Information**
<!--Please specify your platform and versions of the relevant libraries you are
using:-->
  * Operating System: Fedora 31
  * Python Version: 3.7.5
  * yt version: 3.6dev0 (pulled today)
  * Other Libraries (if applicable): 

<!--Please tell us how you installed yt and python e.g., from source,
pip, conda. If you installed from conda, please specify which channel you used
if not the default-->

yt installed from source from the git repo.


Discussion:
I encountered this problem before. It's fixed if you add the line `slc.set_log('density',True)`
just before `slc.save()`.

Note that yt outputs a warning stating 
```
yt : [WARNING  ] 2020-01-28 20:55:28,806 Plot image for field ('gas', 'density') has both positive and negative values. Min = -98628296951477488.000000, Max = 99755406016341008.000000.
yt : [WARNING  ] 2020-01-28 20:55:28,806 Switching to symlog colorbar scaling unless linear scaling is specified later
```
so I assume this behavior is intended since it switched to symlog scalig...?
thanks I'll give that a try!  It may be intended, but it is not intuitive to ignore the limits a user requests, so it might be good to have an option to disable the symlog scaling.

Resolving patch:
diff --git a/yt/visualization/plot_container.py b/yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -906,6 +906,8 @@ def set_zlim(self, field, zmin, zmax, dynamic_range=None):
                 else:
                     myzmin = myzmax / dynamic_range
 
+            if myzmin > 0.0 and self._field_transform[field] == symlog_transform:
+                self._field_transform[field] = log_transform
             self.plots[field].zmin = myzmin
             self.plots[field].zmax = myzmax
         return self


Test patch: