bugfix for plot for string x values
State: closed

- [ ] closes #18687
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Matplotlib can handle string data, so `_get_xticks` does not need to convert strings to int

Labels:
name: Bug
name: Visualization
description: plotting

Comments:
can you add a whatsnew note in 0.22
can you add a test for this
Hello @boeddeker! Thanks for updating the PR.





Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on February 11, 2018 at 11:29 Hours UTC
I add a whatsnew note and a test 
pls rebase
Ok, I did a rebase with master.
But I was not able to merge my changes in whats new, so I dropped my note there.
```
- Bug in :func:`DataFrame.plot` the second call writing in the same figure where both have ``x`` values of type string overwrote the ``xticklabels`` of the first call (:issue:`18687`)
-
```
Can you add another commit with the release note? Those need to be included in the docs.

It looks like this changes is failing other tests: https://travis-ci.org/pandas-dev/pandas/jobs/340101818#L2288. Do those fail for you locally?
Where should I add a release note? The file where I originally added the note, has completely changed.

Regarding the test, the test also fails local on my machine.
I think the reason is that there is a bug in matplotlib, because the example below does not return the expected plot. `get_xticklabels` is empty (i.e. all values are Text(0,0,'')), while the plot contains labels.
So maybe a bugfix in matplotlib is recommented, before this PR is merged into pandas.
```python
_, ax = plt.subplots()
ax.plot(x, y)
ax.set_xticks([1, 2])  # -> x labels: ['', 'a', 'b']
print('xticklabels', list(ax.get_xticklabels()))  # xticklabels [Text(0,0,''), Text(0,0,'')]
print('xticks', list(ax.get_xticks()))  # xticks [1.0, 2.0]


_, ax = plt.subplots()
ax.plot(x, y)
ax.set_xticks(['b', 'c'])  # -> x labels: ['', 'a', 'b']
print('xticklabels', list(ax.get_xticklabels()))  # xticklabels [Text(0,0,''), Text(0,0,'')]
print('xticks', list(ax.get_xticks()))  # xticks [1.0, 2.0]

```

note goes in whatsnew  for 0.23.0 / bugfixes / plotting
According to https://github.com/matplotlib/matplotlib/issues/10547 matplotlib will change in version 2.2 (currently it is 2.2.rc1) the categorical code, so in my mind, this PR could only be merged, when pandas set the minimum required version of matplotlib to version 2.2.

I do not know, what pandas convention is for requiring a minimum version of a library, especially in the case of matplotlib (The `install_requires` in setup.py does not contain matplotlib)

Our minimum matplotlib is pretty old. We usually work around bugs.

@boeddeker does your test pass on matplotlib 2.2? I think the best thing to do is get pandas passing on matplotlib 2.2 (https://github.com/pandas-dev/pandas/pull/19702) and skip this test on MPL older than 2.2. 

Could you also post images of the output on MPL 2.1 and MPL 2.2?
I haven't installed matplotlib 2.2 because my cases work. When Version 2.2 is released, I will investigate how there categorical plot work and further work on this PR.
@TomAugspurger should we fix / close this?
We should get this passing and merged.

@boeddeker can you track down why the CI tests failed?
@TomAugspurger Currently I am busy, but in two weeks I have time. I will take care of this PR in two weeks.
closing as stale, if you want to continue working, pls ping and we can re-open. you will need to merge master.