将x轴值更改为字符串值 [英] Change the x-axis values to string values

查看:71
本文介绍了将x轴值更改为字符串值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的条形图.可以说,它正在绘制不同城市列表的销售价值($).

I have a simple bar chart. Lets say it is plotting the sales value ($) for a list of different cities.

因此,我的y轴是销售额的美元价值.我的x轴是城市列表.在Matlab中,我的x轴上的城市绘制为1到25.如何将数字从1更改为25到字符串值,例如圣地亚哥,纽约,伦敦等?知道如何将字符串值旋转45度也很有用,因为字符串值可能会彼此重叠,从而难以阅读.

So my y-axis is the dollar value of sales. My x-axis is the list of cities. In matlab the cities in my x-axis are plotted as 1 to 25. How do I change the numbers from 1 to 25 to a string values, i.e. San Diego, New York, London etc? Also it would be useful to know how to rotate the string values 45 degrees as the string values might overlap each other making it hard to read.

推荐答案

您应使用例如,

set(gca,'XTickLabel',{'San Diego';'New York';'London';'Chicago'})

这篇关于将x轴值更改为字符串值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆