Repository: optuna/optuna

Issue:
Fix labels on the `matplotlib.plot_contour` with more than two params
<!-- Please write a clear and concise description of what the bug is. -->

## Expected behavior

The red circled part should be fixed since the actual range is `(-100, 100)`.

<img width="484" alt="Screenshot 2021-10-25 at 21 26 49" src="https://user-images.githubusercontent.com/7121753/138695549-3d5dbe3e-ab9a-4b6f-a1f4-60404c5aab58.png">

As a reference, plotly's counter plot is as follows:

<img width="1020" alt="Screenshot 2021-10-25 at 21 30 10" src="https://user-images.githubusercontent.com/7121753/138695303-7b024ec2-bcab-4942-bdf0-a2f1c95bb418.png">




## Environment

- Optuna version:3.0.0a1.dev
- Python version:3.8.12
- OS:macOS-10.16-x86_64-i386-64bit
- (Optional) Other libraries and their versions:
    - matplotlib                    3.4.2
    - plotly                        5.3.1


## Steps to reproduce

Please run the following code. Note that the plot with two params: `optuna.visualization.matplotlib.plot_contour(study, params=["y", "x"])` is fine.

## Reproducible examples (optional)
```python
import optuna


def objective(trial):
    x = trial.suggest_float("x", -100, 100)
    y = trial.suggest_categorical("y", [-1, 0, 1])
    z = trial.suggest_categorical("z", [-1, 0, 1])    
    return x ** 2 + y - z


sampler = optuna.samplers.TPESampler(seed=10)
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=30)

optuna.visualization.matplotlib.plot_contour(study)
```

## Additional context (optional)

<!-- Please add any other context or screenshots about the problem here. -->



Discussion:

Resolving patch:
diff --git a/optuna/visualization/matplotlib/_contour.py b/optuna/visualization/matplotlib/_contour.py
--- a/optuna/visualization/matplotlib/_contour.py
+++ b/optuna/visualization/matplotlib/_contour.py
@@ -311,35 +311,36 @@ def _calculate_griddata(
     xi = np.array([])
     yi = np.array([])
     zi = np.array([])
-    if x_param != y_param:
-        if _is_log_scale(trials, x_param):
-            padding_x = (np.log10(x_values_max) - np.log10(x_values_min)) * AXES_PADDING_RATIO
-            x_values_min = np.power(np.log10(x_values_min) - padding_x, 10)
-            x_values_max = np.power(np.log10(x_values_max) + padding_x, 10)
-            xi = np.logspace(np.log10(x_values_min), np.log10(x_values_max), contour_point_num)
-            x_array = np.log10(x_values)
-        else:
-            padding_x = (x_values_max - x_values_min) * AXES_PADDING_RATIO
-            x_values_min -= padding_x
-            x_values_max += padding_x
-            xi = np.linspace(x_values_min, x_values_max, contour_point_num)
-            x_array = np.array(x_values)
 
-        if _is_log_scale(trials, y_param):
-            padding_y = (np.log10(y_values_max) - np.log10(y_values_min)) * AXES_PADDING_RATIO
-            y_values_min = np.power(np.log10(y_values_min) - padding_y, 10)
-            y_values_max = np.power(np.log10(y_values_max) + padding_y, 10)
-            yi = np.logspace(np.log10(y_values_min), np.log10(y_values_max), contour_point_num)
-            y_array = np.log10(y_values)
-        else:
-            padding_y = (y_values_max - y_values_min) * AXES_PADDING_RATIO
-            y_values_min -= padding_y
-            y_values_max += padding_y
-            yi = np.linspace(y_values_min, y_values_max, contour_point_num)
-            y_array = np.array(y_values)
-
-        # create irregularly spaced map of trial values
-        # and interpolate it with Plotly algorithm
+    if _is_log_scale(trials, x_param):
+        padding_x = (np.log10(x_values_max) - np.log10(x_values_min)) * AXES_PADDING_RATIO
+        x_values_min = np.power(np.log10(x_values_min) - padding_x, 10)
+        x_values_max = np.power(np.log10(x_values_max) + padding_x, 10)
+        xi = np.logspace(np.log10(x_values_min), np.log10(x_values_max), contour_point_num)
+        x_array = np.log10(x_values)
+    else:
+        padding_x = (x_values_max - x_values_min) * AXES_PADDING_RATIO
+        x_values_min -= padding_x
+        x_values_max += padding_x
+        xi = np.linspace(x_values_min, x_values_max, contour_point_num)
+        x_array = np.array(x_values)
+
+    if _is_log_scale(trials, y_param):
+        padding_y = (np.log10(y_values_max) - np.log10(y_values_min)) * AXES_PADDING_RATIO
+        y_values_min = np.power(np.log10(y_values_min) - padding_y, 10)
+        y_values_max = np.power(np.log10(y_values_max) + padding_y, 10)
+        yi = np.logspace(np.log10(y_values_min), np.log10(y_values_max), contour_point_num)
+        y_array = np.log10(y_values)
+    else:
+        padding_y = (y_values_max - y_values_min) * AXES_PADDING_RATIO
+        y_values_min -= padding_y
+        y_values_max += padding_y
+        yi = np.linspace(y_values_min, y_values_max, contour_point_num)
+        y_array = np.array(y_values)
+
+    # create irregularly spaced map of trial values
+    # and interpolate it with Plotly algorithm
+    if x_param != y_param:
         zmap = _create_zmap(x_array, y_array, z_values, xi, yi)
         _interpolate_zmap(zmap, contour_point_num)
         zi = _create_zmatrix_from_zmap(zmap, contour_point_num)
@@ -399,10 +400,9 @@ def _generate_contour_subplot(
     )
     cs = None
     ax.set(xlabel=x_param, ylabel=y_param)
+    ax.set_xlim(x_values_range[0], x_values_range[1])
+    ax.set_ylim(y_values_range[0], y_values_range[1])
     if len(zi) > 0:
-        ax.set_xlim(x_values_range[0], x_values_range[1])
-        ax.set_ylim(y_values_range[0], y_values_range[1])
-        ax.set(xlabel=x_param, ylabel=y_param)
         if _is_log_scale(trials, x_param):
             ax.set_xscale("log")
         if _is_log_scale(trials, y_param):


Test patch: