首页 \ 问答 \ Matlab:如何检索标题,xlabel,ylabel和plotyy字体?(Matlab: how do I retrieve the title, the xlabel, the ylabel and font of a plotyy?)

Matlab:如何检索标题,xlabel,ylabel和plotyy字体?(Matlab: how do I retrieve the title, the xlabel, the ylabel and font of a plotyy?)

我有一些数据,我想改变它们:

  1. 标题
  2. xlabel和ylabel(字体大小和内容)
  3. 刻度尺寸。

这就是我通常这样做的方式:

title('new title ');
xlhand = get(gca,'xlabel');
set(xlhand,'string','xlabel','fontsize',13);
ylhand = get(gca,'ylabel');
set(ylhand,'string','ylabel','fontsize',13);
set(gca,'FontSize',13);

它通常工作正常。 但是,当我想编辑使用ploty函数创建的绘图时,它不起作用。 唯一的影响是我的右ylabel改变了。

我知道,因为我现在有两个ylabels ,改变它们并不像普通情节那么容易。 但是,我很惊讶我无法更改x标签和标题。 这是为什么?

上面的代码与plotxy函数有什么关系? 我怎样才能使它工作? 该文档不包含任何相关信息。

我正在使用Matlab R2015a。

编辑:是的,我的意思是情节 (我的问题中有一个错字)。 以下是文档中的示例代码:

x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);

figure % new figure
plotyy(x,y1,x,y2) 

I have some figures, for which I want to change:

  1. The title
  2. The xlabel and the ylabel (both font size and content)
  3. The ticks size.

This is how I usually do it:

title('new title ');
xlhand = get(gca,'xlabel');
set(xlhand,'string','xlabel','fontsize',13);
ylhand = get(gca,'ylabel');
set(ylhand,'string','ylabel','fontsize',13);
set(gca,'FontSize',13);

It usually works fine. However, it doesn't work when I want to edit a plot made with the ploty function. The only effect is that my right ylabel changes.

I'm aware that since I have two ylabels now, changing them won't be as easy as for a normal plot. However, I'm surprised that I can't change the xlabels and the title. Why is that?

What's wrong with the above code in relation to the plotxy function? How can I make it work? The documentation doesn't contain any relevant information.

I'm using Matlab R2015a.

Edit: Yes, I meant plotyy (there was a typo in my question). Here is sample code from the documentation:

x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);

figure % new figure
plotyy(x,y1,x,y2) 

原文:https://stackoverflow.com/questions/38332262
更新时间:2023-07-28 08:07

最满意答案

在处理JSX语法之前,您需要设置Babel。

有两个选项:将配置添加到package.json ,或创建一个名为.babelrc的文件,其中包含配置。

首先,安装babel-preset-react

$ npm i babel-preset-react --save

接下来,将以下内容添加到package.json

"babel": {
  "presets": [ "react" ]
}

(或者将那个没有“babel”键的对象添加到.babelrc

您可能想要使用的另一个预设是babel-preset-es2015 ,您可以以类似的方式添加它(只需将其添加到presets数组)。

关于Babel配置的更多文档在这里这里 (特别是对于es2015 )。


You need to set up Babel before it can handle JSX syntax.

There are two options: add the configuration to your package.json, or create a file called .babelrc that contains the configuration.

First, install babel-preset-react:

$ npm i babel-preset-react --save

Next, add the following to your package.json:

"babel": {
  "presets": [ "react" ]
}

(or add that object, without the "babel" key, to .babelrc)

Another preset that you may likely want to use is babel-preset-es2015, which you can add in a similar fashion (just add it to the presets array).

More documentation on Babel configuration here and here (specifically for es2015).

相关问答

更多
  • 它告诉你花了这么长时间。 这条信息: Model Block: "before each" hook: 对应于此之前的beforeEach通话: describe('', function() { describe('Model Block:', function() { beforeEach(function(done) { block = new Block({ //.... 如果你想知道为什么需要这么长时间,你可以 ...
  • 正如您在评论中已经明确指出的那样,测试深度嵌套的代码很困难。 使用回调或承诺通常会好得多,因此应用程序的每个部分都将处理它负责的部分,但不会(更多)。 所以你的路由处理程序将处理请求和响应。 显然可以调用其他函数,比如执行数据库查询的函数,但不是让这些函数发回响应,而是使用回调函数“回调”到查询结果的路由处理程序。 像这样的东西: server.get('/api/v1/account_types', function(req, res, next) { select.query_list(QUERY, ...
  • 有一个babel/register风格的钩子忽略样式导入: https://www.npmjs.com/package/ignore-styles 安装它: npm install --save-dev ignore-styles 运行测试没有样式: mocha --require ignore-styles There is a babel/register style hook to ignore style imports: https://www.npmjs.com/package/ignore-s ...
  • 在处理JSX语法之前,您需要设置Babel。 有两个选项:将配置添加到package.json ,或创建一个名为.babelrc的文件,其中包含配置。 首先,安装babel-preset-react : $ npm i babel-preset-react --save 接下来,将以下内容添加到package.json : "babel": { "presets": [ "react" ] } (或者将那个没有“babel”键的对象添加到.babelrc ) 您可能想要使用的另一个预设是babel- ...
  • 看起来Mocha正在尝试将CSS文件加载为Javascript。 我过去使用ignore-styles解决了这个问题。 请参阅: https : //stackoverflow.com/a/34375878/379358 (根据请求移动评论) It looks like Mocha is trying to load a CSS file as Javascript. I have solved this problem in the past using ignore-styles. See: https ...
  • 正如mustaccio BEGIN , END语句不允许在存储过程之外。 请参阅: Hibernate多个本机SQL语句 As stated by mustaccio BEGIN and END statements are not allowed outside of stored procedueres. See: Hibernate multiple native SQL statements
  • 您可以创建场景对象并为每个循环包装执行(我在此示例中使用lodash ): describe("should count the number of combinations correctly", function () { var scenarios = { "2-item arrays": { arrays: { vowels: ['a', 'e'], consonants: ['b', ...
  • 我从这里找到了解决方法 确保您的应用程序在package.json中的相同版本中包含所有关联依赖项 反应-插件-测试- utils的 应对 反应-DOM "react": "^0.14.7", "react-addons-test-utils": "^0.14.7", "react-dom": "^0.14.7", 或升级到上述依赖项的最新版本 I found a work around for this from here make sure that your app contains follow ...
  • 要在测试中找到更多的真/假,你可以从Sinon间谍那里得到args: const spyCall = onLoginClick.getCall(0); expect(spyCall.args[0]).to.equal(expected) 现在失败的测试应该向你展示你真正得到的args。 见http://sinonjs.org/docs/ To find out more then true/false in your test, you can can get the args from the Sino ...
  • 问题是使用Enzyme的shallow而不是mount ,这在测试HOC时是必需的。 所以,使用mount 。 我将此添加到github项目中,以便您可以看到。 使用我的redux-form-test项目并确保使用stackoverflow-question-38106763分支。 请参阅tests/unit/index.js文件。 请务必阅读测试文件的源代码。 其中一项测试无意故意重现您的问题。 在这种情况下,棘手的是HOC的渲染方法完全复制了它包装的组件。 请参阅您提到的react-onclickout ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)