また、プロット軸を科学的記数法ではなく固定記数法で表示することにも取り組みました。私にとって最も苛立たしい部分は、ティックラベルを手動で固定表記に再割り当てした後でも、「x10^4」ラベルがプロットボックスの端に残ることでした。最後に、上記の投稿のおかげで、フィギュアレンダラーで問題を追跡しました。私は「OpenGL」を使用していました。「zbuffer」に変更した場合、ティックラベルを手動でリセットすると、「x10^4」ラベルが適切に消えていました。これは、フォーマット「###、###。0」をy軸ラベルに適用し、ズーム/パンなどのときにyラベルを動的に更新するサンプルコードです。これは、 Matlabファイル交換。他の2つの関数を見つける場所は、関数例の下にコメントとして含まれています。
function []=TickFixExample()
figure %this one works
myRenderer='zbuffer';
set(gcf,'Renderer', myRenderer);
axesh = axes();
set(gca,'YLim',[20000 20100]);
title(myRenderer)
ticklabelformat(gca,'y','###,###.0');
figure %this one doesn’t work
myRenderer='OpenGL';
set(gcf,'Renderer', myRenderer);
axesh = axes();
set(gca,'YLim',[20000 20100]);
title(myRenderer)
ticklabelformat(gca,'y','###,###.0');
Y. Altmanによる関数ticklabelformat(hAxes、axName、format)は、http:
//www.mathworks.com/matlabcentral/fileexchange/36254-ticklabelformat-set-a-dynamic-format-of-axes-tickにあります。 -ラベルまたはグーグルで' ticklabelformatmatlab
'次のように105行目を変更して少し変更しました。
tickLabels = arrayfun(@(x)(FormatNumberScalarInputStrOutput`(x,format)),tickValues,'UniformOutput',false);`
Altmanのバージョンの代わりに:
tickLabels = arrayfun(@(x)(sprintf(format,x)),tickValues,'UniformOutput',false);
この変更により、S。Lienhardによる関数y = NumberFormatter(Numbers、FormatPattern)による数千のコンマ区切り機能が提供されます。これもMatlabファイル交換で行われます。Lienhardコードの私の修正バージョンは、以下に完全に示されています。
function y = FormatNumberScalarInputStrOutput(Number ,FormatPattern)
% adapted 12-2012 by D. Bourgoyne from NUMBERFORMATTER by S. Lienhard
%
% The pound sign (#) denotes a digit, the comma is a placeholder for the
% grouping separator, and the period is a placeholder for the decimal
% separator.
% The pattern specifies leading and trailing zeros, because the 0
% character is used instead of the pound sign (#).
%
% Examples:
% NumberFormatter(rand(5),'0.000')
% NumberFormatter(rand(5)*100,'###,###.000')
import java.text.*
v = DecimalFormat(FormatPattern);
y = char(v.format(Number));