Matlab:如何检索标题,xlabel,ylabel和plotyy字体?(Matlab: how do I retrieve the title, the xlabel, the ylabel and font of a plotyy?)
我有一些数据,我想改变它们:
- 标题
- xlabel和ylabel(字体大小和内容)
- 刻度尺寸。
这就是我通常这样做的方式:
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:
- The title
- The xlabel and the ylabel (both font size and content)
- 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
最满意答案
在处理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
数组)。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 thepresets
array).More documentation on Babel configuration here and here (specifically for
es2015
).
相关问答
更多-
摩卡测试导致超时错误(mocha testing causes a timeout error)[2023-11-24]
它告诉你花了这么长时间。 这条信息: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- ...
-
单元测试react-redux连接组件与Mocha / Chai(Unit testing react-redux connected components with Mocha/Chai)[2023-09-24]
看起来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', ...
-
使用React进行测试(Testing with React)[2022-02-20]
我从这里找到了解决方法 确保您的应用程序在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 ...