2011-09-02 94 views
0

串考慮:列表名稱在數學

daList=Range[10] 

我需要的是標題是列表的名稱,但嘗試:

ListPlot[daList, PlotLabel -> ToString[daList]] 

似乎並沒有工作。

enter image description here

編輯

「daList」 這個稱號我想要的。 SORRY對於以前我以前缺乏精確度

編輯

我又不能老是做任何解決方案的工作,但我想我孤立的問題。列表名稱是繪圖函數參數。我相信,簡單的版本複製我的問題是這樣的:

list = {1, 2, 3, 4}; 
naming[list_] := ToString[HoldForm[list]]; 
naming[list] 

一個低於我的「真實」代碼:

sequenceCountPlot[conditionSet_] := 
ListPlot[sequenceCountALL[conditionSet], 
plotOptions[ 
("DisplayNo looking outside filter" <> (ToString[HoldForm[conditionSet]])), 
"Number of Display", 
"Filter Radius in Cm", 
prefCOLORS], 
PlotRange -> {{0, 10}, {0, [email protected](Max /@ sequenceCountALL[conditionSet])}}, Joined -> True] 

凡plotOptions是一個函數來定製一些選項(標題和顏色)和腳與其他人一起繪製 請知道,即使評估[plotOptions]結果保持不變。

+1

你是什麼意思的字符串轉換?你尋求的結果是什麼? –

+0

您的編輯會增加混淆。你的第一個數字已經有「daList」作爲標題。 –

回答

4

試試這個:

ToString[[email protected]] 

所以如

ListPlot[daList, PlotLabel -> ToString[[email protected]]] 

enter image description here

+0

它在我當前的設置下不起作用,我有一個繪圖函數,它將列表名稱(表達式)作爲輸入:我認爲這反映了問題:list = {1,2,3,4};命名[list_]:= ToString [HoldForm [list]];命名[表]有什麼想法嗎 ? – 500

+0

@ 500這裏:'list = {1,2,3,4}; ClearAll [命名]; SetAttributes [naming,HoldFirst]; naming [list_]:= ToString [HoldForm [list]]'即在定義'命名'前添加'SetAttributes [naming,HoldFirst]' – acl

+0

我即將放棄,它嵌套在我的繪圖功能。你能從這個語法中看到明顯的原因嗎? sequenceCountPlot [conditionSet_]:= ListPlot [sequenceCountALL [conditionSet], plotOptions [( 「DisplayNo看外面濾光」<> 命名[conditionSet]), 「顯示的號碼」, 「過濾半徑在CM」,prefCOLORS] , PlotRange - > {{0,10},{0, Max @(Max/@ sequenceCountALL [conditionSet])}},Joined - > True] – 500

0

可能

ListPlot[daList, PlotLabel -> StringJoin[Map[ToString, daList]]] 

enter image description here

+0

它看起來像所期望的輸出是'daList'(字面上)作爲標題。也許我誤解了這個問題。 – acl

+0

我的不好,對不起納賽爾。 @acl,我擔心你會根據我之前缺乏精確性/關注度做出很好的推論。 ;-) – 500

+0

我把它理解爲500想要daList的值作爲字符串。 – Nasser

2

另一種可能性:

ListPlot[daList, PlotLabel -> ToString[Unevaluated[daList]]] 
4

我認爲,兩種最方便的方式來做到這一點是:

daList = Range[10]; 
ListPlot[daList, PlotLabel -> "daList"] 
ListPlot[daList, PlotLabel -> HoldForm[daList]] 

其他可能性:

ListPlot[daList, PlotLabel -> MakeBoxes[daList]] 
ListPlot[daList, PlotLabel -> SymbolName[[email protected]]] 
ListPlot[daList, PlotLabel -> ToString[[email protected]]] 
ListPlot[daList, PlotLabel -> ToString[[email protected]]] 
+0

坦克你阿列克謝。 – 500