Repository: arviz-devs/arviz

Issue:
xlim of traceplot does not cover all range of values
## Description of your problem

xlim of traceplot may not cover all range of traces for discrete variables. For example, if I get two chains: one with mean 28, another one with mean 32. Then the traceplot will show only one bar at x=28 and xlim from 27.5 to 28.5.

![arcolinux_2019-01-27_16-01-25](https://user-images.githubusercontent.com/2173206/51797762-f7b1e300-224c-11e9-8679-44fa1c58d1db.png)

For discrete values I used DiscreteUniform:
```python
timestep=1.5
with pm.Model() as model_two_switches_11:
    delaymean = pm.Uniform('delaymean',1,28,shape=3)
    k = pm.Uniform('k',0.8,8,shape=3)
    
    switch1 = pm.DiscreteUniform('switch1',df['T'].min()//7,df['T'].max()//7-timestep-1)
    switch2 = pm.DiscreteUniform('switch2',switch1+timestep+1,df['T'].max()//7)
    
    idx = tt.switch(df['t'].values>=(switch1*7),0,1)+tt.switch(df['t'].values>=(switch2*7),0,1)
    
    θ = delaymean/tt.gamma(1+1/k)
    delaysd = pm.Deterministic('delaysd',delaymean/tt.gamma(1+1/k)*tt.sqrt(tt.gamma(1+2/k)-tt.gamma(1+1/k)**2))
    
    delay_p = (1-tt.exp(-(df['δt0'].values/θ[idx])**k[idx]))/(1-tt.exp(-(df['δt'].values/θ[idx])**k[idx]))
    
    confirmed = pm.Poisson('confirmed',\
                    mu=df['confirmed'].values*delay_p+0.001,\
                    observed=df['confirmed0'].values)
    
    start = {'switch1': 22, 'switch2': 28}
    step = pm.Slice([switch1,switch2])
    trace_two_switches_11 = pm.sample(number_of_iterations, tune=length_of_tunein, cores = number_of_jobs,
                                      start=start, step=step)

model_two_switches_11.name = 'Two switches_11'

vrnames = ['switch1','switch2','delaymean','delaysd']
pm.traceplot(trace_two_switches_11,varnames=vrnames);
pm.summary(trace_two_switches_11)
```

ps: I assume that it's because the fraction of those points outside of chosen xlim-range is rather small, but it would be nice to see the consistent picture between left and right panels

## Versions and main components

* PyMC3 Version: 3.6
* Theano Version: 1.0.3
* Python Version: 3.7.1
* Operating system: linux
* How did you install PyMC3: (conda/pip) latest version from github


Discussion:
This is with pip arviz?

I think we could force minimum xlim length to 3 with discrete parameters.
Thank you for your reply. Probably I needed to give more details - my issue was orinally posted on pymc3, but I was then directed here, see https://github.com/pymc-devs/pymc3/issues/3359.

I used the default provided by pymc3, and I didn't call out arviz specifically in my program.
@aakhmetz thanks for reporting this problem. I think I know were is the problem, I will check and send a PR soon. @ahartikainen I think this is due to how we set the `xticks` for histograms
Ok, sound good.

Resolving patch:
diff --git a/arviz/plots/traceplot.py b/arviz/plots/traceplot.py
--- a/arviz/plots/traceplot.py
+++ b/arviz/plots/traceplot.py
@@ -149,6 +149,9 @@ def plot_trace(
             else:
                 plot_kde(row, textsize=xt_labelsize, ax=axes[idx, 0], **kde_kwargs)
 
+        if value[0].dtype.kind == "i":
+            xticks = get_bins(value, max_bins=10, fenceposts=1)
+            axes[idx, 0].set_xticks(xticks)
         axes[idx, 0].set_yticks([])
         for col in (0, 1):
             axes[idx, col].set_title(make_label(var_name, selection), fontsize=titlesize, wrap=True)
@@ -222,6 +225,4 @@ def _histplot_op(ax, data, **kwargs):
     """Add a histogram for the data to the axes."""
     bins = get_bins(data)
     ax.hist(data, bins=bins, align="left", density=True, **kwargs)
-    xticks = get_bins(data, max_bins=10, fenceposts=1)
-    ax.set_xticks(xticks)
     return ax


Test patch: